Re: [PATCH] media: intel-ipu3: cio2: Synchronize irqs at stop_streaming

2018-02-07 Thread Sakari Ailus
Hi Yong,

On Wed, Feb 07, 2018 at 02:47:50PM -0800, Yong Zhi wrote:
> This is to avoid pending interrupts to be handled during
> stream off, in which case, the ready buffer will be removed
> from buffer list, thus not all buffers can be returned to VB2
> as expected. Disable CIO2 irq at cio2_hw_exit() so no new
> interrupts are generated.
> 
> Signed-off-by: Yong Zhi 
> Signed-off-by: Tianshu Qiu 
> ---
>  drivers/media/pci/intel/ipu3/ipu3-cio2.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c 
> b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> index 725973f..8d75146 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -518,6 +518,8 @@ static void cio2_hw_exit(struct cio2_device *cio2, struct 
> cio2_queue *q)
>   unsigned int i, maxloops = 1000;
>  
>   /* Disable CSI receiver and MIPI backend devices */
> + writel(0, q->csi_rx_base + CIO2_REG_IRQCTRL_MASK);
> + writel(0, q->csi_rx_base + CIO2_REG_IRQCTRL_ENABLE);
>   writel(0, q->csi_rx_base + CIO2_REG_CSIRX_ENABLE);
>   writel(0, q->csi_rx_base + CIO2_REG_MIPIBE_ENABLE);
>  
> @@ -1027,6 +1029,7 @@ static void cio2_vb2_stop_streaming(struct vb2_queue 
> *vq)
>   "failed to stop sensor streaming\n");
>  
>   cio2_hw_exit(cio2, q);
> + synchronize_irq(cio2->pci_dev->irq);

Shouldn't this be put in cio2_hw_exit(), which is called from multiple
locations? Presumably the same issue exists there, too.

>   cio2_vb2_return_all_buffers(q, VB2_BUF_STATE_ERROR);
>   media_pipeline_stop(&q->vdev.entity);
>   pm_runtime_put(&cio2->pci_dev->dev);

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


cron job: media_tree daily build: ERRORS

2018-02-07 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 Feb  8 05:00:18 CET 2018
media-tree git hash:273caa260035c03d89ad63d72d8cd3d9e5c5e3f1
media_build git hash:   b52cf3d6c0070f2a166639233301cb47e0f468b6
v4l-utils git hash: 3455539533895a43adc14f579e0987a128181d83
gcc version:i686-linux-gcc (GCC) 7.3.0
sparse version: v0.5.0-3994-g45eb2282
smatch version: v0.5.0-3994-g45eb2282
host hardware:  x86_64
host os:4.14.0-364

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: OK
linux-git-arm-stm32: OK
linux-git-arm64: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
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.98-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.12.67-i686: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.53-i686: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.18.93-i686: ERRORS
linux-3.19-i686: ERRORS
linux-4.0.9-i686: ERRORS
linux-4.1.49-i686: WARNINGS
linux-4.2.8-i686: WARNINGS
linux-4.3.6-i686: WARNINGS
linux-4.4.115-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.80-i686: WARNINGS
linux-4.14.17-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.98-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.12.67-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.53-x86_64: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.93-x86_64: ERRORS
linux-3.19-x86_64: ERRORS
linux-4.0.9-x86_64: ERRORS
linux-4.1.49-x86_64: WARNINGS
linux-4.2.8-x86_64: WARNINGS
linux-4.3.6-x86_64: WARNINGS
linux-4.4.115-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.80-x86_64: WARNINGS
linux-4.14.17-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK
smatch: OK

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


RE: [PATCH 0/8] Add support for multi-planar formats and 10 bit formats

2018-02-07 Thread Satish Kumar Nagireddy
Hi Sakari,

Thanks for the review. I will provide the rst documentation.

Regards,
Satish

> -Original Message-
> From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
> ow...@vger.kernel.org] On Behalf Of Sakari Ailus
> Sent: Wednesday, February 07, 2018 2:34 PM
> To: Satish Kumar Nagireddy 
> Cc: linux-media@vger.kernel.org; laurent.pinch...@ideasonboard.com;
> michal.si...@xilinx.com; Hyun Kwon ; Satish Kumar
> Nagireddy 
> Subject: Re: [PATCH 0/8] Add support for multi-planar formats and 10 bit
> formats
> 
> Hi Satish,
> 
> On Wed, Feb 07, 2018 at 02:29:30PM -0800, Satish Kumar Nagireddy wrote:
> > Jeffrey Mouroux (1):
> >   uapi: media: New fourcc codes needed by Xilinx Video IP
> >
> > Rohit Athavale (1):
> >   media-bus: uapi: Add YCrCb 420 media bus format
> 
> Could you add ReST documentation for these formats?
> 
> --
> Regards,
> 
> Sakari Ailus
> e-mail: sakari.ai...@iki.fi


Re: [PATCH 2/2] drm: adv7511: Add support for i2c_new_secondary_device

2018-02-07 Thread Kieran Bingham
Hi Archit,

On 07/02/18 12:33, Kieran Bingham wrote:
> Hi Archit,
> 
> Thank you for your review,
> 



>>>   unsigned int val;
>>>   int ret;
>>>   @@ -1153,24 +1151,35 @@ static int adv7511_probe(struct i2c_client *i2c,
>>> const struct i2c_device_id *id)
>>>   if (ret)
>>>   goto uninit_regulators;
>>>   -    regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, 
>>> edid_i2c_addr);
>>> -    regmap_write(adv7511->regmap, ADV7511_REG_PACKET_I2C_ADDR,
>>> - main_i2c_addr - 0xa);
> 
> 
> Packet address here is written as an offset of -0x0a, which gives 0x2f or 
> 0x33 ... ?
> 
> I think these current offsets are platform specific to a specific platform :)

I appear to be using platform specific maths specific to a non-conforming
platform or universe :-)

Sorry for the incorrect assertion here. - I mixed up 8bit and 7bit values.

The offsets are valid (when calculated correctly) - however - as per my reply to
Laurent - I believe the patch which determined the offsets was using the wrong
base :).

Also - due to a hardware issue on the ADV7511 - the Wheat (as the only known
user of two chips on the same bus) will need to be updated to ensure the current
assignments don't conflict.

--
Kieran



Re: [PATCH 2/2] drm: adv7511: Add support for i2c_new_secondary_device

2018-02-07 Thread Kieran Bingham
Hi Laurent,

On 07/02/18 21:59, Laurent Pinchart wrote:
> Hi Kieran,
> 
> On Wednesday, 7 February 2018 17:14:09 EET Kieran Bingham wrote:
>> On 29/01/18 10:26, Laurent Pinchart wrote:
>>> On Monday, 22 January 2018 14:50:00 EET Kieran Bingham wrote:
 The ADV7511 has four 256-byte maps that can be accessed via the main I²C
 ports. Each map has it own I²C address and acts as a standard slave
 device on the I²C bus.

 Allow a device tree node to override the default addresses so that
 address conflicts with other devices on the same bus may be resolved at
 the board description level.

 Signed-off-by: Kieran Bingham 
 ---

  .../bindings/display/bridge/adi,adv7511.txt| 10 +-
>>>
>>> I don't mind personally, but device tree maintainers usually ask for DT
>>> bindings changes to be split to a separate patch.
>>>
  drivers/gpu/drm/bridge/adv7511/adv7511.h   |  4 +++
  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c   | 36 ++-
  3 files changed, 37 insertions(+), 13 deletions(-)

 diff --git
 a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
 b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
 index 0047b1394c70..f6bb9f6d3f48 100644
 --- a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
 +++ b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt

 @@ -70,6 +70,9 @@ Optional properties:
rather than generate its own timings for HDMI output.
  
  - clocks: from common clock binding: reference to the CEC clock.
  - clock-names: from common clock binding: must be "cec".

 +- reg-names : Names of maps with programmable addresses.
 +  It can contain any map needing a non-default address.
 +  Possible maps names are : "main", "edid", "cec", "packet"
>>>
>>> Is the reg-names property (and the additional maps) mandatory or optional
>>> ? If mandatory you should also update the existing DT sources that use
>>> those bindings.
>>
>> They are currently optional. I do prefer it that way - but perhaps due to an
>> issue mentioned below we might need to make this driver mandatory ?
>>
>>> If optional you should define which I2C addresses will be used when
>>> the maps are not specified (and in that case I think we should go for
>>> the addresses listed as default in the datasheet, which correspond to the
>>> current driver implementation when the main address is 0x3d/0x7a).
>>
>> The current addresses do not correspond to the datasheet, even when the
>> implementation main address is set to 0x3d.
> 
> Don't they ? The driver currently uses the following (8-bit) I2C addresses:
> 
> EDID:   main + 4  = 0x7e (0x3f)
> Packet: main - 10 = 0x70 (0x38)
> CEC:main - 2  = 0x78 (0x3c)
> 
> Those are the default addresses according to section 4.1 of the ADV7511W 
> programming guide (rev. B), and they match the ones you set in this patch.

Sorry - I was clearly subtracting 8bit values from a 7bit address in my failed
assertion, to both you and Archit.



>> Thus, in my opinion - they are currently 'wrong' - but perhaps changing them
>> is considered breakage too.
>>
>> A particular issue will arise here too - as on this device - when the device
>> is in low-power mode (after probe, before use) - the maps will respond on
>> their *hardware default* addresses (the ones implemented in this patch),
>> and thus consume that address on the I2C bus regardless of their settings
>> in the driver.
> 
> We've discussed this previously and I share you concern. Just to make sure I 
> remember correctly, did all the secondary maps reset to their default 
> addresses, or just the EDID map ?


The following responds on the bus when programmed at alternative addresses, and
in low power mode. The responses are all 0, but that's still going to conflict
with other hardware if it tries to use the 'un-used' addresses.

Packet (0x38),
Main (0x39),
Fixed (set to 0 by software, but shows up at 0x3e)
and EDID (0x3f).

So actually it's only the CEC which don't respond when in "low-power-mode".


As far as I can see, (git grep  -B3 adi,adv75) - The r8a7792-wheat.dts is the
only instance of a device using 0x3d, which means that Sergei's patch changed
the behaviour of all the existing devices before that.

Thus - this patch could be seen to be a 'correction' back to the original
behaviour for all devices except the Wheat, and possibly devices added after
Sergei's patch went in.

However - by my understanding, - any device which has only one ADV75(3,1)+
should use the hardware defined addresses (the hardware defaults will be
conflicting on the bus anyway, thus should be assigned to the ADV7511)

Any platform which uses *two* ADV7511 devices on the same bus should actually
set *both* devices to use entirely separate addresses - or they will still
conflict with each other.

Now - if my understanding is correct - then I believe - that means that

RE: [PATCH v4 00/12] Intel IPU3 ImgU patchset

2018-02-07 Thread Mani, Rajmohan
Hi Mauro,

> -Original Message-
> From: Mani, Rajmohan
> Sent: Tuesday, December 26, 2017 2:31 PM
> To: 'Mauro Carvalho Chehab' 
> Cc: Zhi, Yong ; linux-media@vger.kernel.org;
> sakari.ai...@linux.intel.com; Zheng, Jian Xu ;
> Toivonen, Tuukka ; Hu, Jerry W
> ; a...@arndb.de; h...@lst.de;
> robin.mur...@arm.com; io...@lists.linux-foundation.org
> Subject: RE: [PATCH v4 00/12] Intel IPU3 ImgU patchset
> 
> Hi Mauro,
> 
> > -Original Message-
> > From: Mauro Carvalho Chehab [mailto:mche...@s-opensource.com]
> > Sent: Wednesday, December 20, 2017 5:58 AM
> > To: Mani, Rajmohan 
> > Cc: Zhi, Yong ; linux-media@vger.kernel.org;
> > sakari.ai...@linux.intel.com; Zheng, Jian Xu
> > ; Toivonen, Tuukka
> > ; Hu, Jerry W ;
> > a...@arndb.de; h...@lst.de; robin.mur...@arm.com;
> > io...@lists.linux-foundation.org
> > Subject: Re: [PATCH v4 00/12] Intel IPU3 ImgU patchset
> >
> > Hi,
> >
> > Em Fri, 17 Nov 2017 02:58:56 +
> > "Mani, Rajmohan"  escreveu:
> >
> > > Here is an update on the IPU3 documentation that we are currently
> > > working
> > on.
> > >
> > > Image processing in IPU3 relies on the following.
> > >
> > > 1) HW configuration to enable ISP and
> > > 2) setting customer specific 3A Tuning / Algorithm Parameters to
> > > achieve
> > desired image quality.
> > >
> > > We intend to provide documentation on ImgU driver programming
> > > interface
> > to help users of this driver to configure and enable ISP HW to meet
> > their needs.  This documentation will include details on complete V4L2
> > Kernel driver interface and IO-Control parameters, except for the ISP
> > internal algorithm and its parameters (which is Intel proprietary IP).
> >
> > Sakari asked me to take a look on this thread, specifically on this
> > email. I took a look on the other e-mails from this thread that are
> > discussing about this IP block.
> >
> > I understand that Intel wants to keep their internal 3A algorithm
> > protected, just like other vendors protect their own algos. It was
> > never a requirement to open whatever algorithm are used inside a
> > hardware (or firmware). The only requirement is that firmwares should
> > be licensed with redistribution permission, ideally merged at linux-firmware
> git tree.
> >
> > Yet, what I don't understand is why Intel also wants to also protect
> > the interface for such 3A hardware/firmware algorithm. The parameters
> > that are passed from an userspace application to Intel ISP logic
> > doesn't contain the algorithm itself. What's the issue of documenting
> > the meaning of each parameter?
> >
> 
> Thanks for looking into this.
> 
> To achieve improved image quality using IPU3, 3A (Auto White balance, Auto
> Focus and Auto Exposure) Tuning parameters specific to a given camera sensor
> module, are converted to Intel ISP algorithm parameters in user space camera
> HAL using AIC (Automatic ISP Configuration) library.
> 
> As a unique design of Intel ISP, it exposes very detailed algorithm parameters
> (~ 1 parameters) to configure ISP's image processing algorithm per each
> image fame in runtime. Typical Camera SW developers (including those at
> Intel) are not expected to fully understand and directly set these parameters 
> to
> configure the ISP algorithm blocks. Due to the above, a user space AIC library
> (in binary form) is provided to generate ISP Algorithm specific parameters, 
> for a
> given set of 3A tuning parameters. It significantly reduces the efforts of SW
> development in ISP HW configuration.
> 
> On the other hand, the ISP algorithm details could be deduced readily through
> these detailed parameters by other ISP experts outside Intel. This is the 
> reason
> that we want to keep these parameter definitions as Intel proprietary IP.
> 
> We are fully aware of your concerns on how to enable open source developers
> to use Intel ISP through up-streamed Kernel Driver. Internally, we are working
> on the license for this AIC library release now (as Hans said NDA license is 
> not
> acceptable). We believe this will be more efficient way to help open source
> developers.
> 
> This AIC library release would be a binary-only release. This AIC library 
> does not
> use any kernel uAPIs directly. The user space Camera HAL that uses kernel
> uAPIs is available at
> https://chromium.googlesource.com/chromiumos/platform/arc-
> camera/+/master
> 

Just pinging to know your thoughts on this.

Thanks
Raj


[PATCH] media: intel-ipu3: cio2: Synchronize irqs at stop_streaming

2018-02-07 Thread Yong Zhi
This is to avoid pending interrupts to be handled during
stream off, in which case, the ready buffer will be removed
from buffer list, thus not all buffers can be returned to VB2
as expected. Disable CIO2 irq at cio2_hw_exit() so no new
interrupts are generated.

Signed-off-by: Yong Zhi 
Signed-off-by: Tianshu Qiu 
---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c 
b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index 725973f..8d75146 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -518,6 +518,8 @@ static void cio2_hw_exit(struct cio2_device *cio2, struct 
cio2_queue *q)
unsigned int i, maxloops = 1000;
 
/* Disable CSI receiver and MIPI backend devices */
+   writel(0, q->csi_rx_base + CIO2_REG_IRQCTRL_MASK);
+   writel(0, q->csi_rx_base + CIO2_REG_IRQCTRL_ENABLE);
writel(0, q->csi_rx_base + CIO2_REG_CSIRX_ENABLE);
writel(0, q->csi_rx_base + CIO2_REG_MIPIBE_ENABLE);
 
@@ -1027,6 +1029,7 @@ static void cio2_vb2_stop_streaming(struct vb2_queue *vq)
"failed to stop sensor streaming\n");
 
cio2_hw_exit(cio2, q);
+   synchronize_irq(cio2->pci_dev->irq);
cio2_vb2_return_all_buffers(q, VB2_BUF_STATE_ERROR);
media_pipeline_stop(&q->vdev.entity);
pm_runtime_put(&cio2->pci_dev->dev);
-- 
1.9.1



[PATCH v9 0/8] TDA1997x HDMI video reciver

2018-02-07 Thread Tim Harvey
This is a v4l2 subdev driver supporting the TDA1997x HDMI video receiver.

I've tested this on a Gateworks GW54xx/GW551x with an IMX6Q/IMX6DL which
uses the TDA19971 with 16bits connected to the IMX6 CSI and single-lane
I2S audio providing 2-channel audio.

For this configuration I've tested both 16bit YUV422 and 8bit
BT656 parallel video bus modes.

While the driver should support the TDA1993 I do not have one for testing.

Further potential development efforts include:
 - CEC support
 - HDCP support
 - TDA19972 support (2 inputs)

Media graphs can be found at http://dev.gateworks.com/docs/linux/media

History:
v9:
 - add digital video decoder video interface entity function

v8:
 - fix clearing pad for VIDIOC_DV_TIMIGNS_CAP
 - support full range of input modes based on timings_cap
 - add patch to fix clearing pad for VIDIOC_DV_TIMIGINGS
 - fix available formats for tda19971 bt656 bus width >12
 - fix set_format (compliance)
 - fixed get/set edid (compliance)
 - add init_cfg to setup default pad config (compliance)
 - added missing pad checks to get_dv_timings_cap/enum_dv_timings (compliance)
 - fix alignment of if statement and whitespace in comment (Hans)
 - move regs to tda1997x_regs.h to clean up (Hans)
 - add define and sanity check for num of mbus_codes (Hans)

v7:
 - fix interlaced mode
 - support no AVI infoframe (ie DVI) (Hans)
 - add support for multiple output formats (Hans)

v6:
 - tda1997x: fix return on regulator enablei in tda1997x_set_power() (Fabio)
 - tda1997x: fix colorspace handling (Hans)
 - bindings: added Robs's ack (Rob)
 - replace copyright with SPDX tag (Philippe)

v5:
 - added v4l2_hdmi_colorimetry() patch from Hans to series
 - bindings: added Sakari's ack
 - tda1997x: uppercase string constants
 - tda1997x: use v4l2_hdmi_rx_coloriemtry to fill format
 - tda1997x: fix V4L2_CID_DV_RX_RGB_RANGE
 - tda1997x: fix interlaced mode format
 - dts: remove leading 0 from unit address
 - dts: add newline between property list and child node
 - dts: added missing audmux in GW551x dts

v4:
 - move include/dt-bindings/media/tda1997x.h to bindings patch
 - clarify port node details in bindings
 - fix typos
 - fix default quant range for VGA
 - fix quant range handling and conv matrix
 - add additional standards and capabilities to timings_cap

v3:
 - fix typo in dt bindings
 - added dt bindings for GW551x
 - use V4L2_DV_BT_FRAME_WIDTH/HEIGHT macros
 - fixed missing break
 - use only hdmi_infoframe_log for infoframe logging
 - simplify tda1997x_s_stream error handling
 - add delayed work proc to handle hotplug enable/disable
 - fix set_edid (disable HPD before writing, enable after)
 - remove enabling edid by default
 - initialize timings
 - take quant range into account in colorspace conversion
 - remove vendor/product tracking (we provide this in log_status via
   infoframes)
 - add v4l_controls
 - add more detail to log_status
 - calculate vhref generator timings
 - timing detection fixes (rounding errors, hswidth errors)
 - rename configure_input/configure_conv functions

v2:
 - encorporate feedback into dt bindings
 - change audio dt bindings
 - implement dv timings enum/cap
 - remove deprecated g_mbus_config op
 - fix dv_query_timings
 - add EDID get/set handling
 - remove max-pixel-rate support
 - add audio codec DAI support
 - added media-ctl and v4l2-compliance details

v1:
 - initial RFC

# media-ctl -d /dev/media0 -p
Media controller API version 4.15.0

Media device information

driver  imx-media
model   imx-media
serial  
bus info
hw revision 0x0
driver version  4.15.0

Device topology
- entity 1: adv7180 2-0020 (1 pad, 1 link)
type V4L2 subdev subtype Unknown flags 20004
device node name /dev/v4l-subdev0
pad0: Source
[fmt:UYVY8_2X8/720x480 field:interlaced colorspace:smpte170m]
-> "ipu2_csi1_mux":1 []

- entity 3: tda19971 2-0048 (1 pad, 1 link)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev1
pad0: Source
[fmt:UYVY8_2X8/1280x720 field:none colorspace:srgb]
[dv.caps:BT.656/1120 min:640x350@1300 
max:1920x1200@16500 stds:CEA-861,DMT,CVT,GTF 
caps:interlaced,progressive,reduced-blanking,custom]
[dv.detect:BT.656/1120 1280x720p60 (1650x750) stds:CEA-861 
flags:can-reduce-fps,CE-video,has-cea861-vic]
[dv.current:BT.656/1120 1280x720p60 (1650x750) stds:CEA-861 
flags:can-reduce-fps,CE-video,has-cea861-vic]
-> "ipu1_csi0_mux":1 [ENABLED]

- entity 5: ipu1_vdic (3 pads, 3 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev2
pad0: Sink
[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m 
xfer:709 ycbcr:601 quantization:lim-range]
<- "ipu1_csi0":1 []
<- "ipu1_csi1":1 []
pad1: Sink
[fmt

[PATCH v9 2/8] media: v4l-ioctl: fix clearing pad for VIDIOC_DV_TIMIGNS_CAP

2018-02-07 Thread Tim Harvey
Signed-off-by: Tim Harvey 
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 7961499..5f3670d 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2638,7 +2638,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
IOCTL_INFO_FNC(VIDIOC_PREPARE_BUF, v4l_prepare_buf, v4l_print_buffer, 
INFO_FL_QUEUE),
IOCTL_INFO_STD(VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings, 
v4l_print_enum_dv_timings, INFO_FL_CLEAR(v4l2_enum_dv_timings, pad)),
IOCTL_INFO_STD(VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings, 
v4l_print_dv_timings, INFO_FL_ALWAYS_COPY),
-   IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, 
v4l_print_dv_timings_cap, INFO_FL_CLEAR(v4l2_dv_timings_cap, type)),
+   IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, 
v4l_print_dv_timings_cap, INFO_FL_CLEAR(v4l2_dv_timings_cap, pad)),
IOCTL_INFO_FNC(VIDIOC_ENUM_FREQ_BANDS, v4l_enum_freq_bands, 
v4l_print_freq_band, 0),
IOCTL_INFO_FNC(VIDIOC_DBG_G_CHIP_INFO, v4l_dbg_g_chip_info, 
v4l_print_dbg_chip_info, INFO_FL_CLEAR(v4l2_dbg_chip_info, match)),
IOCTL_INFO_FNC(VIDIOC_QUERY_EXT_CTRL, v4l_query_ext_ctrl, 
v4l_print_query_ext_ctrl, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_query_ext_ctrl, 
id)),
-- 
2.7.4



[PATCH v9 1/8] v4l2-dv-timings: add v4l2_hdmi_colorimetry()

2018-02-07 Thread Tim Harvey
From: Hans Verkuil 

Add the v4l2_hdmi_colorimetry() function so we have a single function
that determines the colorspace, YCbCr encoding, quantization range and
transfer function from the InfoFrame data.

Cc: Randy Dunlap 
Signed-off-by: Hans Verkuil 
---
v9:
 - fix kernel-doc format (Randy)
 - remove redundant pad bounds check already in v4l2-subdev.c
 - assign entity function (Hans)
 - properly assign/check/free ctrl_handler (Hans)
 - fixed typo 'Rull Range' -> 'Full Range'
 - update csc after quant range change

 drivers/media/v4l2-core/v4l2-dv-timings.c | 141 ++
 include/media/v4l2-dv-timings.h   |  21 +
 2 files changed, 162 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c 
b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 930f9c5..5663d86 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 MODULE_AUTHOR("Hans Verkuil");
 MODULE_DESCRIPTION("V4L2 DV Timings Helper Functions");
@@ -814,3 +815,143 @@ struct v4l2_fract v4l2_calc_aspect_ratio(u8 
hor_landscape, u8 vert_portrait)
return aspect;
 }
 EXPORT_SYMBOL_GPL(v4l2_calc_aspect_ratio);
+
+/** v4l2_hdmi_rx_colorimetry - determine HDMI colorimetry information
+ * based on various InfoFrames.
+ * @avi: the AVI InfoFrame
+ * @hdmi: the HDMI Vendor InfoFrame, may be NULL
+ * @height: the frame height
+ *
+ * Determines the HDMI colorimetry information, i.e. how the HDMI
+ * pixel color data should be interpreted.
+ *
+ * Note that some of the newer features (DCI-P3, HDR) are not yet
+ * implemented: the hdmi.h header needs to be updated to the HDMI 2.0
+ * and CTA-861-G standards.
+ */
+struct v4l2_hdmi_colorimetry
+v4l2_hdmi_rx_colorimetry(const struct hdmi_avi_infoframe *avi,
+const struct hdmi_vendor_infoframe *hdmi,
+unsigned int height)
+{
+   struct v4l2_hdmi_colorimetry c = {
+   V4L2_COLORSPACE_SRGB,
+   V4L2_YCBCR_ENC_DEFAULT,
+   V4L2_QUANTIZATION_FULL_RANGE,
+   V4L2_XFER_FUNC_SRGB
+   };
+   bool is_ce = avi->video_code || (hdmi && hdmi->vic);
+   bool is_sdtv = height <= 576;
+   bool default_is_lim_range_rgb = avi->video_code > 1;
+
+   switch (avi->colorspace) {
+   case HDMI_COLORSPACE_RGB:
+   /* RGB pixel encoding */
+   switch (avi->colorimetry) {
+   case HDMI_COLORIMETRY_EXTENDED:
+   switch (avi->extended_colorimetry) {
+   case HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB:
+   c.colorspace = V4L2_COLORSPACE_ADOBERGB;
+   c.xfer_func = V4L2_XFER_FUNC_ADOBERGB;
+   break;
+   case HDMI_EXTENDED_COLORIMETRY_BT2020:
+   c.colorspace = V4L2_COLORSPACE_BT2020;
+   c.xfer_func = V4L2_XFER_FUNC_709;
+   break;
+   default:
+   break;
+   }
+   break;
+   default:
+   break;
+   }
+   switch (avi->quantization_range) {
+   case HDMI_QUANTIZATION_RANGE_LIMITED:
+   c.quantization = V4L2_QUANTIZATION_LIM_RANGE;
+   break;
+   case HDMI_QUANTIZATION_RANGE_FULL:
+   break;
+   default:
+   if (default_is_lim_range_rgb)
+   c.quantization = V4L2_QUANTIZATION_LIM_RANGE;
+   break;
+   }
+   break;
+
+   default:
+   /* YCbCr pixel encoding */
+   c.quantization = V4L2_QUANTIZATION_LIM_RANGE;
+   switch (avi->colorimetry) {
+   case HDMI_COLORIMETRY_NONE:
+   if (!is_ce)
+   break;
+   if (is_sdtv) {
+   c.colorspace = V4L2_COLORSPACE_SMPTE170M;
+   c.ycbcr_enc = V4L2_YCBCR_ENC_601;
+   } else {
+   c.colorspace = V4L2_COLORSPACE_REC709;
+   c.ycbcr_enc = V4L2_YCBCR_ENC_709;
+   }
+   c.xfer_func = V4L2_XFER_FUNC_709;
+   break;
+   case HDMI_COLORIMETRY_ITU_601:
+   c.colorspace = V4L2_COLORSPACE_SMPTE170M;
+   c.ycbcr_enc = V4L2_YCBCR_ENC_601;
+   c.xfer_func = V4L2_XFER_FUNC_709;
+   break;
+   case HDMI_COLORIMETRY_ITU_709:
+   c.colorspace = V4L2_COLORSPACE_REC709;
+   c.ycbcr_enc = V4L2_YCBCR_ENC_709;
+  

[PATCH v9 6/8] media: i2c: Add TDA1997x HDMI receiver driver

2018-02-07 Thread Tim Harvey
Add support for the TDA1997x HDMI receivers.

Cc: Hans Verkuil 
Signed-off-by: Tim Harvey 
---
v9:
 - remove redundant pad bounds check already in v4l2-subdev.c
 - assign entity function (Hans)
 - properly assign/check/free ctrl_handler (Hans)
 - fixed typo 'Rull Range' -> 'Full Range'
 - update csc after quant range change

v8:
 - fix available formats for tda19971 bt656 bus width >12
 - support full range of input modes based on timings_cap
 - fix set_format (compliance)
 - fixed get/set edid (compliance)
 - add init_cfg to setup default pad config (compliance)
 - added missing pad checks to get_dv_timings_cap/enum_dv_timings (compliance)
 - fix alignment of if statement and whitespace in comment (Hans)
 - move regs to tda1997x_regs.h to clean up (Hans)
 - add define and sanity check for num of mbus_codes (Hans)

v7:
 - fix interlaced mode
 - support no AVI infoframe (ie DVI) (Hans)
 - add support for multiple output formats (Hans)

v6:
 - fix return on regulator enablei in tda1997x_set_power()
 - replace copyright with SPDX tag
 - fix colorspace handling

v5:
 - uppercase string constants
 - use v4l2_hdmi_rx_coloriemtry to fill format
 - fix V4L2_CID_DV_RX_RGB_RANGE
 - fix interlaced mode format

v4:
 - move include/dt-bindings/media/tda1997x.h to bindings patch
 - fix typos
 - fix default quant range for VGA
 - fix quant range handling and conv matrix
 - add additional standards and capabilities to timings_cap

v3:
 - use V4L2_DV_BT_FRAME_WIDTH/HEIGHT macros
 - fixed missing break
 - use only hdmi_infoframe_log for infoframe logging
 - simplify tda1997x_s_stream error handling
 - add delayed work proc to handle hotplug enable/disable
 - fix set_edid (disable HPD before writing, enable after)
 - remove enabling edid by default
 - initialize timings
 - take quant range into account in colorspace conversion
 - remove vendor/product tracking (we provide this in log_status via infoframes)
 - add v4l_controls
 - add more detail to log_status
 - calculate vhref generator timings
 - timing detection fixes (rounding errors, hswidth errors)
 - rename configure_input/configure_conv functions

v2:
 - implement dv timings enum/cap
 - remove deprecated g_mbus_config op
 - fix dv_query_timings
 - add EDID get/set handling
 - remove max-pixel-rate support
 - add audio codec DAI support
 - change audio bindings

 drivers/media/i2c/Kconfig |9 +
 drivers/media/i2c/Makefile|1 +
 drivers/media/i2c/tda1997x.c  | 2848 +
 drivers/media/i2c/tda1997x_regs.h |  641 +
 include/media/i2c/tda1997x.h  |   42 +
 5 files changed, 3541 insertions(+)
 create mode 100644 drivers/media/i2c/tda1997x.c
 create mode 100644 drivers/media/i2c/tda1997x_regs.h
 create mode 100644 include/media/i2c/tda1997x.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index cb5d7ff..3522641 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -56,6 +56,15 @@ config VIDEO_TDA9840
  To compile this driver as a module, choose M here: the
  module will be called tda9840.
 
+config VIDEO_TDA1997X
+   tristate "NXP TDA1997x HDMI receiver"
+   depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
+   ---help---
+ V4L2 subdevice driver for the NXP TDA1997x HDMI receivers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called tda1997x.
+
 config VIDEO_TEA6415C
tristate "Philips TEA6415C audio processor"
depends on I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..adfcae9 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o
 obj-$(CONFIG_VIDEO_TDA7432) += tda7432.o
 obj-$(CONFIG_VIDEO_SAA6588) += saa6588.o
 obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o
+obj-$(CONFIG_VIDEO_TDA1997X) += tda1997x.o
 obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o
 obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o
 obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o
diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
new file mode 100644
index 000..87af02b
--- /dev/null
+++ b/drivers/media/i2c/tda1997x.c
@@ -0,0 +1,2848 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Gateworks Corporation
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "tda1997x_regs.h"
+
+#define TDA1997X_MBUS_CODES5
+
+/* debug level */
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "debug level (0-2)");
+
+/* Audio formats */
+static const char * const audtype_names[] = {
+   "PCM",  /* PCM Samples */
+   "HBR",  /* High Bit Rate Audio */
+   "OBA",  /* 

[PATCH v9 3/8] media: add digital video decoder entity function

2018-02-07 Thread Tim Harvey
Add a new media entity function definition for digital TV decoders:
MEDIA_ENT_F_DTV_DECODER

Signed-off-by: Tim Harvey 
---
 Documentation/media/uapi/mediactl/media-types.rst | 11 +++
 include/uapi/linux/media.h|  5 +
 2 files changed, 16 insertions(+)

diff --git a/Documentation/media/uapi/mediactl/media-types.rst 
b/Documentation/media/uapi/mediactl/media-types.rst
index 8d64b0c..195400e 100644
--- a/Documentation/media/uapi/mediactl/media-types.rst
+++ b/Documentation/media/uapi/mediactl/media-types.rst
@@ -321,6 +321,17 @@ Types and flags used to represent the media graph elements
  MIPI CSI-2, ...), and outputs them on its source pad to an output
  video bus of another type (eDP, MIPI CSI-2, parallel, ...).
 
+-  ..  row 31
+
+   ..  _MEDIA-ENT-F-DTV-DECODER:
+
+   -  ``MEDIA_ENT_F_DTV_DECODER``
+
+   -  Digital video decoder. The basic function of the video decoder is
+ to accept digital video from a wide variety of sources
+ and output it in some digital video standard, with appropriate
+ timing signals.
+
 ..  tabularcolumns:: |p{5.5cm}|p{12.0cm}|
 
 .. _media-entity-flag:
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index b9b9446..2f12328 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -110,6 +110,11 @@ struct media_device_info {
 #define MEDIA_ENT_F_VID_IF_BRIDGE  (MEDIA_ENT_F_BASE + 0x5002)
 
 /*
+ * Digital video decoder entities
+ */
+#define MEDIA_ENT_F_DTV_DECODER(MEDIA_ENT_F_BASE + 
0x6001)
+
+/*
  * Connectors
  */
 /* It is a responsibility of the entity drivers to add connectors and links */
-- 
2.7.4



[PATCH v9 5/8] media: dt-bindings: Add bindings for TDA1997X

2018-02-07 Thread Tim Harvey
Acked-by: Rob Herring 
Acked-by: Sakari Ailus 
Signed-off-by: Tim Harvey 
---
v6:
 - replace copyright with SPDX tag
 - added Rob's ack

v5:
 - added Sakari's ack

v4:
 - move include/dt-bindings/media/tda1997x.h to bindings patch
 - clarify port node details

v3:
 - fix typo

v2:
 - add vendor prefix and remove _ from vidout-portcfg
 - remove _ from labels
 - remove max-pixel-rate property
 - describe and provide example for single output port
 - update to new audio port bindings

 .../devicetree/bindings/media/i2c/tda1997x.txt | 179 +
 include/dt-bindings/media/tda1997x.h   |  74 +
 2 files changed, 253 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/tda1997x.txt
 create mode 100644 include/dt-bindings/media/tda1997x.h

diff --git a/Documentation/devicetree/bindings/media/i2c/tda1997x.txt 
b/Documentation/devicetree/bindings/media/i2c/tda1997x.txt
new file mode 100644
index 000..9ab53c3
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/tda1997x.txt
@@ -0,0 +1,179 @@
+Device-Tree bindings for the NXP TDA1997x HDMI receiver
+
+The TDA19971/73 are HDMI video receivers.
+
+The TDA19971 Video port output pins can be used as follows:
+ - RGB 8bit per color (24 bits total): R[11:4] B[11:4] G[11:4]
+ - YUV444 8bit per color (24 bits total): Y[11:4] Cr[11:4] Cb[11:4]
+ - YUV422 semi-planar 8bit per component (16 bits total): Y[11:4] CbCr[11:4]
+ - YUV422 semi-planar 10bit per component (20 bits total): Y[11:2] CbCr[11:2]
+ - YUV422 semi-planar 12bit per component (24 bits total): - Y[11:0] CbCr[11:0]
+ - YUV422 BT656 8bit per component (8 bits total): YCbCr[11:4] (2-cycles)
+ - YUV422 BT656 10bit per component (10 bits total): YCbCr[11:2] (2-cycles)
+ - YUV422 BT656 12bit per component (12 bits total): YCbCr[11:0] (2-cycles)
+
+The TDA19973 Video port output pins can be used as follows:
+ - RGB 12bit per color (36 bits total): R[11:0] B[11:0] G[11:0]
+ - YUV444 12bit per color (36 bits total): Y[11:0] Cb[11:0] Cr[11:0]
+ - YUV422 semi-planar 12bit per component (24 bits total): Y[11:0] CbCr[11:0]
+ - YUV422 BT656 12bit per component (12 bits total): YCbCr[11:0] (2-cycles)
+
+The Video port output pins are mapped via 4-bit 'pin groups' allowing
+for a variety of connection possibilities including swapping pin order within
+pin groups. The video_portcfg device-tree property consists of register mapping
+pairs which map a chip-specific VP output register to a 4-bit pin group. If
+the pin group needs to be bit-swapped you can use the *_S pin-group defines.
+
+Required Properties:
+ - compatible  :
+  - "nxp,tda19971" for the TDA19971
+  - "nxp,tda19973" for the TDA19973
+ - reg : I2C slave address
+ - interrupts  : The interrupt number
+ - DOVDD-supply: Digital I/O supply
+ - DVDD-supply : Digital Core supply
+ - AVDD-supply : Analog supply
+ - nxp,vidout-portcfg  : array of pairs mapping VP output pins to pin groups.
+
+Optional Properties:
+ - nxp,audout-format   : DAI bus format: "i2s" or "spdif".
+ - nxp,audout-width: width of audio output data bus (1-4).
+ - nxp,audout-layout   : data layout (0=AP0 used, 1=AP0/AP1/AP2/AP3 used).
+ - nxp,audout-mclk-fs  : Multiplication factor between stream rate and codec
+ mclk.
+
+The port node shall contain one endpoint child node for its digital
+output video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Optional Endpoint Properties:
+  The following three properties are defined in video-interfaces.txt and
+  are valid for the output parallel bus endpoint:
+  - hsync-active: Horizontal synchronization polarity. Defaults to active high.
+  - vsync-active: Vertical synchronization polarity. Defaults to active high.
+  - data-active: Data polarity. Defaults to active high.
+
+Examples:
+ - VP[15:0] connected to IMX6 CSI_DATA[19:4] for 16bit YUV422
+   16bit I2S layout0 with a 128*fs clock (A_WS, AP0, A_CLK pins)
+   hdmi-receiver@48 {
+   compatible = "nxp,tda19971";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_tda1997x>;
+   reg = <0x48>;
+   interrupt-parent = <&gpio1>;
+   interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+   DOVDD-supply = <®_3p3v>;
+   AVDD-supply = <®_1p8v>;
+   DVDD-supply = <®_1p8v>;
+   /* audio */
+   #sound-dai-cells = <0>;
+   nxp,audout-format = "i2s";
+   nxp,audout-layout = <0>;
+   nxp,audout-width = <16>;
+   nxp,audout-mclk-fs = <128>;
+   /*
+* The 8bpp YUV422 semi-planar mode outputs CbCr[11:4]
+* and Y[11:4] across 16bits in the same pixclk cycle.
+*/
+   nxp,vidout-portcfg =
+   /* Y[11:8]<->VP[15:12]<->CSI_DATA[1

[PATCH v9 8/8] ARM: dts: imx: Add TDA19971 HDMI Receiver to GW551x

2018-02-07 Thread Tim Harvey
Signed-off-by: Tim Harvey 
---
v5:
 - add missing audmux config

 arch/arm/boot/dts/imx6qdl-gw551x.dtsi | 138 ++
 1 file changed, 138 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl-gw551x.dtsi 
b/arch/arm/boot/dts/imx6qdl-gw551x.dtsi
index 30d4662..749548a 100644
--- a/arch/arm/boot/dts/imx6qdl-gw551x.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-gw551x.dtsi
@@ -46,6 +46,8 @@
  */
 
 #include 
+#include 
+#include 
 
 / {
/* these are used by bootloader for disabling nodes */
@@ -98,6 +100,50 @@
regulator-min-microvolt = <500>;
regulator-max-microvolt = <500>;
};
+
+   sound-digital {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "tda1997x-audio";
+
+   simple-audio-card,dai-link@0 {
+   format = "i2s";
+
+   cpu {
+   sound-dai = <&ssi2>;
+   };
+
+   codec {
+   bitclock-master;
+   frame-master;
+   sound-dai = <&tda1997x>;
+   };
+   };
+   };
+};
+
+&audmux {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_audmux>; /* AUD5<->tda1997x */
+   status = "okay";
+
+   ssi1 {
+   fsl,audmux-port = <0>;
+   fsl,port-config = <
+   (IMX_AUDMUX_V2_PTCR_TFSDIR |
+   IMX_AUDMUX_V2_PTCR_TFSEL(4+8) | /* RXFS */
+   IMX_AUDMUX_V2_PTCR_TCLKDIR |
+   IMX_AUDMUX_V2_PTCR_TCSEL(4+8) | /* RXC */
+   IMX_AUDMUX_V2_PTCR_SYN)
+   IMX_AUDMUX_V2_PDCR_RXDSEL(4)
+   >;
+   };
+
+   aud5 {
+   fsl,audmux-port = <4>;
+   fsl,port-config = <
+   IMX_AUDMUX_V2_PTCR_SYN
+   IMX_AUDMUX_V2_PDCR_RXDSEL(0)>;
+   };
 };
 
 &can1 {
@@ -263,6 +309,60 @@
#gpio-cells = <2>;
};
 
+   tda1997x: tda1997x@48 {
+   compatible = "nxp,tda19971";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_tda1997x>;
+   reg = <0x48>;
+   interrupt-parent = <&gpio1>;
+   interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+   DOVDD-supply = <®_3p3>;
+   AVDD-supply = <®_1p8b>;
+   DVDD-supply = <®_1p8a>;
+   #sound-dai-cells = <0>;
+   nxp,audout-format = "i2s";
+   nxp,audout-layout = <0>;
+   nxp,audout-width = <16>;
+   nxp,audout-mclk-fs = <128>;
+   /*
+* The 8bpp YUV422 semi-planar mode outputs CbCr[11:4]
+* and Y[11:4] across 16bits in the same cycle
+* which we map to VP[15:08]<->CSI_DATA[19:12]
+*/
+   nxp,vidout-portcfg =
+   /*G_Y_11_8<->VP[15:12]<->CSI_DATA[19:16]*/
+   < TDA1997X_VP24_V15_12 TDA1997X_G_Y_11_8 >,
+   /*G_Y_7_4<->VP[11:08]<->CSI_DATA[15:12]*/
+   < TDA1997X_VP24_V11_08 TDA1997X_G_Y_7_4 >,
+   /*R_CR_CBCR_11_8<->VP[07:04]<->CSI_DATA[11:08]*/
+   < TDA1997X_VP24_V07_04 TDA1997X_R_CR_CBCR_11_8 >,
+   /*R_CR_CBCR_7_4<->VP[03:00]<->CSI_DATA[07:04]*/
+   < TDA1997X_VP24_V03_00 TDA1997X_R_CR_CBCR_7_4 >;
+
+   port {
+   tda1997x_to_ipu1_csi0_mux: endpoint {
+   remote-endpoint = 
<&ipu1_csi0_mux_from_parallel_sensor>;
+   bus-width = <16>;
+   hsync-active = <1>;
+   vsync-active = <1>;
+   data-active = <1>;
+   };
+   };
+   };
+};
+
+&ipu1_csi0_from_ipu1_csi0_mux {
+   bus-width = <16>;
+};
+
+&ipu1_csi0_mux_from_parallel_sensor {
+   remote-endpoint = <&tda1997x_to_ipu1_csi0_mux>;
+   bus-width = <16>;
+};
+
+&ipu1_csi0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu1_csi0>;
 };
 
 &pcie {
@@ -320,6 +420,14 @@
 };
 
 &iomuxc {
+   pinctrl_audmux: audmuxgrp {
+   fsl,pins = <
+   MX6QDL_PAD_DISP0_DAT19__AUD5_RXD0x130b0
+   MX6QDL_PAD_DISP0_DAT14__AUD5_RXC0x130b0
+   MX6QDL_PAD_DISP0_DAT13__AUD5_RXFS   0x130b0
+   >;
+   };
+
pinctrl_flexcan1: flexcan1grp {
fsl,pins = <
MX6QDL_PAD_KEY_ROW2__FLEXCAN1_RX0x1b0b1
@@ -375,6 +483,30 @@
>;
};
 
+   pinctrl_ipu1_csi0: ipu1_csi0grp {
+   fsl,pins = <
+   MX6QDL_PAD_CSI0_DAT4__IPU1_CSI0_D

[PATCH v9 7/8] ARM: dts: imx: Add TDA19971 HDMI Receiver to GW54xx

2018-02-07 Thread Tim Harvey
The GW54xx has a front-panel microHDMI connector routed to a TDA19971
which is connected the the IPU CSI when using IMX6Q.

Signed-off-by: Tim Harvey 
---
v5:
 - remove leading 0 from unit address
 - add newline between property list and child node

v4: no changes
v3: no changes

v2:
 - add HDMI audio input support

 arch/arm/boot/dts/imx6q-gw54xx.dts| 105 ++
 arch/arm/boot/dts/imx6qdl-gw54xx.dtsi |  29 +-
 2 files changed, 131 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-gw54xx.dts 
b/arch/arm/boot/dts/imx6q-gw54xx.dts
index 56e5b50..0477120 100644
--- a/arch/arm/boot/dts/imx6q-gw54xx.dts
+++ b/arch/arm/boot/dts/imx6q-gw54xx.dts
@@ -12,10 +12,30 @@
 /dts-v1/;
 #include "imx6q.dtsi"
 #include "imx6qdl-gw54xx.dtsi"
+#include 
 
 / {
model = "Gateworks Ventana i.MX6 Dual/Quad GW54XX";
compatible = "gw,imx6q-gw54xx", "gw,ventana", "fsl,imx6q";
+
+   sound-digital {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "tda1997x-audio";
+
+   simple-audio-card,dai-link@0 {
+   format = "i2s";
+
+   cpu {
+   sound-dai = <&ssi2>;
+   };
+
+   codec {
+   bitclock-master;
+   frame-master;
+   sound-dai = <&tda1997x>;
+   };
+   };
+   };
 };
 
 &i2c3 {
@@ -35,6 +55,61 @@
};
};
};
+
+   tda1997x: codec@48 {
+   compatible = "nxp,tda19971";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_tda1997x>;
+   reg = <0x48>;
+   interrupt-parent = <&gpio1>;
+   interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+   DOVDD-supply = <®_3p3v>;
+   AVDD-supply = <&sw4_reg>;
+   DVDD-supply = <&sw4_reg>;
+   #sound-dai-cells = <0>;
+   nxp,audout-format = "i2s";
+   nxp,audout-layout = <0>;
+   nxp,audout-width = <16>;
+   nxp,audout-mclk-fs = <128>;
+   /*
+* The 8bpp YUV422 semi-planar mode outputs CbCr[11:4]
+* and Y[11:4] across 16bits in the same cycle
+* which we map to VP[15:08]<->CSI_DATA[19:12]
+*/
+   nxp,vidout-portcfg =
+   /*G_Y_11_8<->VP[15:12]<->CSI_DATA[19:16]*/
+   < TDA1997X_VP24_V15_12 TDA1997X_G_Y_11_8 >,
+   /*G_Y_7_4<->VP[11:08]<->CSI_DATA[15:12]*/
+   < TDA1997X_VP24_V11_08 TDA1997X_G_Y_7_4 >,
+   /*R_CR_CBCR_11_8<->VP[07:04]<->CSI_DATA[11:08]*/
+   < TDA1997X_VP24_V07_04 TDA1997X_R_CR_CBCR_11_8 >,
+   /*R_CR_CBCR_7_4<->VP[03:00]<->CSI_DATA[07:04]*/
+   < TDA1997X_VP24_V03_00 TDA1997X_R_CR_CBCR_7_4 >;
+
+   port {
+   tda1997x_to_ipu1_csi0_mux: endpoint {
+   remote-endpoint = 
<&ipu1_csi0_mux_from_parallel_sensor>;
+   bus-width = <16>;
+   hsync-active = <1>;
+   vsync-active = <1>;
+   data-active = <1>;
+   };
+   };
+   };
+};
+
+&ipu1_csi0_from_ipu1_csi0_mux {
+   bus-width = <16>;
+};
+
+&ipu1_csi0_mux_from_parallel_sensor {
+   remote-endpoint = <&tda1997x_to_ipu1_csi0_mux>;
+   bus-width = <16>;
+};
+
+&ipu1_csi0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu1_csi0>;
 };
 
 &ipu2_csi1_from_ipu2_csi1_mux {
@@ -63,6 +138,30 @@
>;
};
 
+   pinctrl_ipu1_csi0: ipu1_csi0grp {
+   fsl,pins = <
+   MX6QDL_PAD_CSI0_DAT4__IPU1_CSI0_DATA04  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT5__IPU1_CSI0_DATA05  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT6__IPU1_CSI0_DATA06  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT7__IPU1_CSI0_DATA07  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT8__IPU1_CSI0_DATA08  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT9__IPU1_CSI0_DATA09  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT10__IPU1_CSI0_DATA10 0x1b0b0
+   MX6QDL_PAD_CSI0_DAT11__IPU1_CSI0_DATA11 0x1b0b0
+   MX6QDL_PAD_CSI0_DAT12__IPU1_CSI0_DATA12 0x1b0b0
+   MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13 0x1b0b0
+   MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14 0x1b0b0
+   MX6QDL_PAD_CSI0_DAT15__IPU1_CSI0_DATA15 0x1b0b0
+   MX6QDL_PAD_CSI0_DAT16__IPU1_CSI0_DATA16 0x1b0b0

[PATCH v9 4/8] MAINTAINERS: add entry for NXP TDA1997x driver

2018-02-07 Thread Tim Harvey
Signed-off-by: Tim Harvey 
---
 MAINTAINERS | 8 
 1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 845fc25..439b500 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13262,6 +13262,14 @@ T: git git://linuxtv.org/mkrufky/tuners.git
 S: Maintained
 F: drivers/media/tuners/tda18271*
 
+TDA1997x MEDIA DRIVER
+M: Tim Harvey 
+L: linux-media@vger.kernel.org
+W: https://linuxtv.org
+Q: http://patchwork.linuxtv.org/project/linux-media/list/
+S: Maintained
+F: drivers/media/i2c/tda1997x.*
+
 TDA827x MEDIA DRIVER
 M: Michael Krufky 
 L: linux-media@vger.kernel.org
-- 
2.7.4



Re: [PATCH] media: intel-ipu3: cio2: Use SPDX license headers

2018-02-07 Thread Sakari Ailus
Hi Yong,

Thanks for the patch.

On Mon, Feb 05, 2018 at 08:19:53PM -0800, Yong Zhi wrote:
> Adopt SPDX license headers and update year to 2018.
> 
> Signed-off-by: Yong Zhi 
> ---
>  drivers/media/pci/intel/ipu3/ipu3-cio2.c | 12 ++--
>  drivers/media/pci/intel/ipu3/ipu3-cio2.h | 14 ++
>  2 files changed, 4 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c 
> b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> index 6cb..725973f 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -1,14 +1,6 @@
> +// SPDX-License-Identifier: GPL-2.0
>  /*
> - * Copyright (c) 2017 Intel Corporation.
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License version
> - * 2 as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> + * Copyright (C) 2018 Intel Corporation
>   *
>   * Based partially on Intel IPU4 driver written by
>   *  Sakari Ailus 
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.h 
> b/drivers/media/pci/intel/ipu3/ipu3-cio2.h
> index 78a5799..6a11051 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.h
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.h
> @@ -1,15 +1,5 @@
> -/*
> - * Copyright (c) 2017 Intel Corporation.
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License version
> - * 2 as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - */
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/* Copyright (C) 2018 Intel Corporation */

Should this be:

/* Copyright (C) 2017 -- 2018 Intel Corporation */

?

Same for the one above.

>  
>  #ifndef __IPU3_CIO2_H
>  #define __IPU3_CIO2_H
> -- 
> 1.9.1
> 

-- 
Sakari Ailus
sakari.ai...@linux.intel.com


Re: [PATCH 0/8] Add support for multi-planar formats and 10 bit formats

2018-02-07 Thread Sakari Ailus
Hi Satish,

On Wed, Feb 07, 2018 at 02:29:30PM -0800, Satish Kumar Nagireddy wrote:
> Jeffrey Mouroux (1):
>   uapi: media: New fourcc codes needed by Xilinx Video IP
> 
> Rohit Athavale (1):
>   media-bus: uapi: Add YCrCb 420 media bus format

Could you add ReST documentation for these formats?

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


[PATCH 5/8] v4l: xilinx: dma: Update video format descriptor

2018-02-07 Thread Satish Kumar Nagireddy
This patch updates video format descriptor to help information
viz., number of planes per color format and chroma sub sampling
factors.

This commit adds the various 8-bit and 10-bit that are supported
to the table queried by drivers.

Signed-off-by: Satish Kumar Nagireddy 
---
 drivers/media/platform/xilinx/xilinx-vip.c | 18 ++
 drivers/media/platform/xilinx/xilinx-vip.h | 11 ++-
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-vip.c 
b/drivers/media/platform/xilinx/xilinx-vip.c
index d306f44..51b7ef6 100644
--- a/drivers/media/platform/xilinx/xilinx-vip.c
+++ b/drivers/media/platform/xilinx/xilinx-vip.c
@@ -27,22 +27,24 @@
  */

 static const struct xvip_video_format xvip_video_formats[] = {
+   { XVIP_VF_YUV_420, 10, NULL, MEDIA_BUS_FMT_VYYUYY8_1X24,
+ 1, 15, V4L2_PIX_FMT_XV15M, 2, 2, 1, 2, "4:2:0, 10-bit 2-plane 
non-cont" },
{ XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16,
- 2, V4L2_PIX_FMT_YUYV, "4:2:2, packed, YUYV" },
+ 2, 16, V4L2_PIX_FMT_YUYV, 1, 1, 2, 1, "4:2:2, packed, YUYV" },
{ XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24,
- 3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" },
+ 3, 24, V4L2_PIX_FMT_VUY24, 1, 1, 1, 1, "4:4:4, packed, YUYV" },
{ XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24,
- 3, V4L2_PIX_FMT_RGB24, "24-bit RGB" },
+ 3, 24, V4L2_PIX_FMT_RGB24, 1, 1, 1, 1, "24-bit RGB" },
{ XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8,
- 1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" },
+ 1, 8, V4L2_PIX_FMT_GREY, 1, 1, 1, 1, "Greyscale 8-bit" },
{ XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8,
- 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit RGGB" },
+ 1, 8, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, "Bayer 8-bit RGGB" },
{ XVIP_VF_MONO_SENSOR, 8, "grbg", MEDIA_BUS_FMT_SGRBG8_1X8,
- 1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit GRBG" },
+ 1, 8, V4L2_PIX_FMT_SGRBG8, 1, 1, 1, 1, "Bayer 8-bit GRBG" },
{ XVIP_VF_MONO_SENSOR, 8, "gbrg", MEDIA_BUS_FMT_SGBRG8_1X8,
- 1, V4L2_PIX_FMT_SGBRG8, "Bayer 8-bit GBRG" },
+ 1, 8, V4L2_PIX_FMT_SGBRG8, 1, 1, 1, 1, "Bayer 8-bit GBRG" },
{ XVIP_VF_MONO_SENSOR, 8, "bggr", MEDIA_BUS_FMT_SBGGR8_1X8,
- 1, V4L2_PIX_FMT_SBGGR8, "Bayer 8-bit BGGR" },
+ 1, 8, V4L2_PIX_FMT_SBGGR8, 1, 1, 1, 1, "Bayer 8-bit BGGR" },
 };

 /**
diff --git a/drivers/media/platform/xilinx/xilinx-vip.h 
b/drivers/media/platform/xilinx/xilinx-vip.h
index 42fee20..006dcf77 100644
--- a/drivers/media/platform/xilinx/xilinx-vip.h
+++ b/drivers/media/platform/xilinx/xilinx-vip.h
@@ -109,8 +109,12 @@ struct xvip_device {
  * @width: AXI4 format width in bits per component
  * @pattern: CFA pattern for Mono/Sensor formats
  * @code: media bus format code
- * @bpp: bytes per pixel (when stored in memory)
+ * @bpl_factor: Bytes per line factor
  * @fourcc: V4L2 pixel format FCC identifier
+ * @num_planes: number of planes w.r.t. color format
+ * @buffers: number of buffers per format
+ * @hsub: Horizontal sampling factor of Chroma
+ * @vsub: Vertical sampling factor of Chroma
  * @description: format description, suitable for userspace
  */
 struct xvip_video_format {
@@ -118,8 +122,13 @@ struct xvip_video_format {
unsigned int width;
const char *pattern;
unsigned int code;
+   unsigned int bpl_factor;
unsigned int bpp;
u32 fourcc;
+   u8 num_planes;
+   u8 buffers;
+   u8 hsub;
+   u8 vsub;
const char *description;
 };

--
2.7.4

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.


[PATCH 6/8] v4l: xilinx: dma: Add multi-planar support

2018-02-07 Thread Satish Kumar Nagireddy
The current v4l driver supports single plane formats. This patch
will add support to handle multi-planar formats. Updated driver
capabilities to multi-planar, where it can handle both single and
multi-planar formats

Signed-off-by: Satish Kumar Nagireddy 
---
 drivers/media/platform/xilinx/xilinx-dma.c  | 343 +++-
 drivers/media/platform/xilinx/xilinx-dma.h  |   2 +-
 drivers/media/platform/xilinx/xilinx-vipp.c |  22 +-
 3 files changed, 309 insertions(+), 58 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-dma.c 
b/drivers/media/platform/xilinx/xilinx-dma.c
index cb20ada..656a87e 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -63,6 +63,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma)
struct v4l2_subdev_format fmt;
struct v4l2_subdev *subdev;
int ret;
+   int width, height;

subdev = xvip_dma_remote_subdev(&dma->pad, &fmt.pad);
if (subdev == NULL)
@@ -73,9 +74,18 @@ static int xvip_dma_verify_format(struct xvip_dma *dma)
if (ret < 0)
return ret == -ENOIOCTLCMD ? -EINVAL : ret;

-   if (dma->fmtinfo->code != fmt.format.code ||
-   dma->format.height != fmt.format.height ||
-   dma->format.width != fmt.format.width)
+   if (dma->fmtinfo->code != fmt.format.code)
+   return -EINVAL;
+
+   if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) {
+   width = dma->format.fmt.pix_mp.width;
+   height = dma->format.fmt.pix_mp.height;
+   } else {
+   width = dma->format.fmt.pix.width;
+   height = dma->format.fmt.pix.height;
+   }
+
+   if (width != fmt.format.width || height != fmt.format.height)
return -EINVAL;

return 0;
@@ -302,6 +312,8 @@ static void xvip_dma_complete(void *param)
 {
struct xvip_dma_buffer *buf = param;
struct xvip_dma *dma = buf->dma;
+   u8 num_planes, i;
+   int sizeimage;

spin_lock(&dma->queued_lock);
list_del(&buf->queue);
@@ -310,7 +322,28 @@ static void xvip_dma_complete(void *param)
buf->buf.field = V4L2_FIELD_NONE;
buf->buf.sequence = dma->sequence++;
buf->buf.vb2_buf.timestamp = ktime_get_ns();
-   vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage);
+
+   if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) {
+   /* Handling contiguous data with mplanes */
+   if (dma->fmtinfo->buffers == 1) {
+   sizeimage =
+   dma->format.fmt.pix_mp.plane_fmt[0].sizeimage;
+   vb2_set_plane_payload(&buf->buf.vb2_buf, 0, sizeimage);
+   } else {
+   /* Handling non-contiguous data with mplanes */
+   num_planes = dma->format.fmt.pix_mp.num_planes;
+   for (i = 0; i < num_planes; i++) {
+   sizeimage =
+dma->format.fmt.pix_mp.plane_fmt[i].sizeimage;
+   vb2_set_plane_payload(&buf->buf.vb2_buf, i,
+ sizeimage);
+   }
+   }
+   } else {
+   sizeimage = dma->format.fmt.pix.sizeimage;
+   vb2_set_plane_payload(&buf->buf.vb2_buf, 0, sizeimage);
+   }
+
vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE);
 }

@@ -320,13 +353,48 @@ xvip_dma_queue_setup(struct vb2_queue *vq,
 unsigned int sizes[], struct device *alloc_devs[])
 {
struct xvip_dma *dma = vb2_get_drv_priv(vq);
+   u8 i;
+   int sizeimage;
+
+   /* Multi planar case: Make sure the image size is large enough */
+   if (V4L2_TYPE_IS_MULTIPLANAR(dma->format.type)) {
+   if (*nplanes) {
+   if (*nplanes != dma->format.fmt.pix_mp.num_planes)
+   return -EINVAL;
+
+   for (i = 0; i < *nplanes; i++) {
+sizeimage =
+ dma->format.fmt.pix_mp.plane_fmt[i].sizeimage;
+   if (sizes[i] < sizeimage)
+   return -EINVAL;
+   }
+   } else {
+   /* Handling contiguous data with mplanes */
+   if (dma->fmtinfo->buffers == 1) {
+   *nplanes = 1;
+   sizes[0] =
+ dma->format.fmt.pix_mp.plane_fmt[0].sizeimage;
+   return 0;
+   } else {
+   /* Handling non-contiguous data with mplanes */
+   *nplanes = dma->format.fmt.pix_mp.num_planes;
+   for (i = 0; i < *nplanes; i++) {
+sizeimage =
+ 

[PATCH 1/8] v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format

2018-02-07 Thread Satish Kumar Nagireddy
From: Radhey Shyam Pandey 

In current implementation driver only checks the colorspace
between the last subdev in the pipeline and the connected video node,
the pipeline could be configured with wrong colorspace information
until the very end. It thus makes little sense to check the
colorspace only at the video node. So check can be dropped until
we find a better solution to carry colorspace information
through pipelines and to userspace.

Signed-off-by: Satish Kumar Nagireddy 
---
 drivers/media/platform/xilinx/xilinx-dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-dma.c 
b/drivers/media/platform/xilinx/xilinx-dma.c
index 522cdfd..cb20ada 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -75,8 +75,7 @@ static int xvip_dma_verify_format(struct xvip_dma *dma)

if (dma->fmtinfo->code != fmt.format.code ||
dma->format.height != fmt.format.height ||
-   dma->format.width != fmt.format.width ||
-   dma->format.colorspace != fmt.format.colorspace)
+   dma->format.width != fmt.format.width)
return -EINVAL;

return 0;
--
2.7.4

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.


[PATCH 4/8] media-bus: uapi: Add YCrCb 420 media bus format

2018-02-07 Thread Satish Kumar Nagireddy
From: Rohit Athavale 

This commit adds a YUV 420 media bus format. Currently, one
doesn't exist. VYYUYY8_1X24 does not describe the way the pixels are
sent over the bus, but is an approximation.

Signed-off-by: Satish Kumar Nagireddy 
---
 include/uapi/linux/media-bus-format.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/media-bus-format.h 
b/include/uapi/linux/media-bus-format.h
index 9e35117..0297e19 100644
--- a/include/uapi/linux/media-bus-format.h
+++ b/include/uapi/linux/media-bus-format.h
@@ -62,7 +62,7 @@
 #define MEDIA_BUS_FMT_RGB121212_1X36   0x1019
 #define MEDIA_BUS_FMT_RGB161616_1X48   0x101a

-/* YUV (including grey) - next is  0x202c */
+/* YUV (including grey) - next is  0x202d */
 #define MEDIA_BUS_FMT_Y8_1X8   0x2001
 #define MEDIA_BUS_FMT_UV8_1X8  0x2015
 #define MEDIA_BUS_FMT_UYVY8_1_5X8  0x2002
@@ -106,6 +106,7 @@
 #define MEDIA_BUS_FMT_YUV12_1X36   0x2029
 #define MEDIA_BUS_FMT_YUV16_1X48   0x202a
 #define MEDIA_BUS_FMT_UYYVYY16_0_5X48  0x202b
+#define MEDIA_BUS_FMT_VYYUYY8_1X24  0x202c

 /* Bayer - next is 0x3021 */
 #define MEDIA_BUS_FMT_SBGGR8_1X8   0x3001
--
2.7.4

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.


[PATCH 3/8] uapi: media: New fourcc codes needed by Xilinx Video IP

2018-02-07 Thread Satish Kumar Nagireddy
From: Jeffrey Mouroux 

The Xilinx Video Framebuffer DMA IP supports video memory formats
that are not represented in the current V4L2 fourcc library. This
patch adds those missing fourcc codes. This includes both new
8-bit and 10-bit pixel formats.

Signed-off-by: Satish Kumar Nagireddy 
---
 include/uapi/linux/videodev2.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 9827189..9fa4313c 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -509,7 +509,10 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_XBGR32  v4l2_fourcc('X', 'R', '2', '4') /* 32  
BGRX-8-8-8-8  */
 #define V4L2_PIX_FMT_RGB32   v4l2_fourcc('R', 'G', 'B', '4') /* 32  
RGB-8-8-8-8   */
 #define V4L2_PIX_FMT_ARGB32  v4l2_fourcc('B', 'A', '2', '4') /* 32  
ARGB-8-8-8-8  */
+#define V4L2_PIX_FMT_BGRA32  v4l2_fourcc('A', 'B', 'G', 'R') /* 32  
ABGR-8-8-8-8  */
 #define V4L2_PIX_FMT_XRGB32  v4l2_fourcc('B', 'X', '2', '4') /* 32  
XRGB-8-8-8-8  */
+#define V4L2_PIX_FMT_BGRX32  v4l2_fourcc('X', 'B', 'G', 'R') /* 32  
XBGR-8-8-8-8 */
+#define V4L2_PIX_FMT_XBGR30  v4l2_fourcc('R', 'X', '3', '0') /* 32  
XBGR-2-10-10-10 */

 /* Grey formats */
 #define V4L2_PIX_FMT_GREYv4l2_fourcc('G', 'R', 'E', 'Y') /*  8  Greyscale  
   */
@@ -537,12 +540,16 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_VYUYv4l2_fourcc('V', 'Y', 'U', 'Y') /* 16  YUV 4:2:2  
   */
 #define V4L2_PIX_FMT_Y41Pv4l2_fourcc('Y', '4', '1', 'P') /* 12  YUV 4:1:1  
   */
 #define V4L2_PIX_FMT_YUV444  v4l2_fourcc('Y', '4', '4', '4') /* 16   
 */
+#define V4L2_PIX_FMT_XVUY32  v4l2_fourcc('X', 'V', '3', '2') /* 32  XVUY 
8:8:8:8 */
+#define V4L2_PIX_FMT_AVUY32  v4l2_fourcc('A', 'V', '3', '2') /* 32  AVUY 
8:8:8:8 */
+#define V4L2_PIX_FMT_VUY24   v4l2_fourcc('V', 'U', '2', '4') /* 24  VUY 8:8:8 
*/
 #define V4L2_PIX_FMT_YUV555  v4l2_fourcc('Y', 'U', 'V', 'O') /* 16  YUV-5-5-5  
   */
 #define V4L2_PIX_FMT_YUV565  v4l2_fourcc('Y', 'U', 'V', 'P') /* 16  YUV-5-6-5  
   */
 #define V4L2_PIX_FMT_YUV32   v4l2_fourcc('Y', 'U', 'V', '4') /* 32  
YUV-8-8-8-8   */
 #define V4L2_PIX_FMT_HI240   v4l2_fourcc('H', 'I', '2', '4') /*  8  8-bit 
color   */
 #define V4L2_PIX_FMT_HM12v4l2_fourcc('H', 'M', '1', '2') /*  8  YUV 4:2:0 
16x16 macroblocks */
 #define V4L2_PIX_FMT_M420v4l2_fourcc('M', '4', '2', '0') /* 12  YUV 4:2:0 
2 lines y, 1 line uv interleaved */
+#define V4L2_PIX_FMT_XVUY10  v4l2_fourcc('X', 'Y', '1', '0') /* 32  XVUY 
2-10-10-10 */

 /* two planes -- one Y, one Cr + Cb interleaved  */
 #define V4L2_PIX_FMT_NV12v4l2_fourcc('N', 'V', '1', '2') /* 12  Y/CbCr 
4:2:0  */
@@ -551,6 +558,8 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_NV61v4l2_fourcc('N', 'V', '6', '1') /* 16  Y/CrCb 
4:2:2  */
 #define V4L2_PIX_FMT_NV24v4l2_fourcc('N', 'V', '2', '4') /* 24  Y/CbCr 
4:4:4  */
 #define V4L2_PIX_FMT_NV42v4l2_fourcc('N', 'V', '4', '2') /* 24  Y/CrCb 
4:4:4  */
+#define V4L2_PIX_FMT_XV20v4l2_fourcc('X', 'V', '2', '0') /* 32  XY/UV 
4:2:2 10-bit */
+#define V4L2_PIX_FMT_XV15v4l2_fourcc('X', 'V', '1', '5') /* 32  XY/UV 
4:2:0 10-bit */

 /* two non contiguous planes - one Y, one Cr + Cb interleaved  */
 #define V4L2_PIX_FMT_NV12M   v4l2_fourcc('N', 'M', '1', '2') /* 12  Y/CbCr 
4:2:0  */
@@ -558,6 +567,8 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_NV16M   v4l2_fourcc('N', 'M', '1', '6') /* 16  Y/CbCr 
4:2:2  */
 #define V4L2_PIX_FMT_NV61M   v4l2_fourcc('N', 'M', '6', '1') /* 16  Y/CrCb 
4:2:2  */
 #define V4L2_PIX_FMT_NV12MT  v4l2_fourcc('T', 'M', '1', '2') /* 12  Y/CbCr 
4:2:0 64x32 macroblocks */
+#define V4L2_PIX_FMT_XV20M   v4l2_fourcc('X', 'M', '2', '0') /* 32  XY/UV 
4:2:2 10-bit */
+#define V4L2_PIX_FMT_XV15M   v4l2_fourcc('X', 'M', '1', '5') /* 32  XY/UV 
4:2:0 10-bit */
 #define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12  
Y/CbCr 4:2:0 16x16 macroblocks */

 /* three planes - Y Cb, Cr */
--
2.7.4

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.


[PATCH 7/8] v4l: xilinx: dma: Add scaling and padding factor functions

2018-02-07 Thread Satish Kumar Nagireddy
scaling_factor function returns multiplying factor to calculate
bytes per component based on color format.
For eg. scaling factor of YUV420 8 bit format is 1
so multiplying factor is 1 (8/8)
scaling factor of YUV420 10 bit format is 1.25 (10/8)

padding_factor function returns multiplying factor to calculate
actual width of video according to color format.
For eg. padding factor of YUV420 8 bit format: 8 bits per 1 component
no padding bits here, so multiplying factor is 1
padding factor of YUV422 10 bit format: 32 bits per 3 components
each component is 10 bit and the factor is 32/30

Signed-off-by: Satish Kumar Nagireddy 
---
 drivers/media/platform/xilinx/xilinx-vip.c | 43 ++
 drivers/media/platform/xilinx/xilinx-vip.h |  2 ++
 2 files changed, 45 insertions(+)

diff --git a/drivers/media/platform/xilinx/xilinx-vip.c 
b/drivers/media/platform/xilinx/xilinx-vip.c
index 51b7ef6..7543b75 100644
--- a/drivers/media/platform/xilinx/xilinx-vip.c
+++ b/drivers/media/platform/xilinx/xilinx-vip.c
@@ -94,6 +94,49 @@ const struct xvip_video_format 
*xvip_get_format_by_fourcc(u32 fourcc)
 EXPORT_SYMBOL_GPL(xvip_get_format_by_fourcc);

 /**
+ * xvip_bpl_scaling_factor - Retrieve bpl scaling factor for a 4CC
+ * @fourcc: the format 4CC
+ *
+ * Return: Return numerator and denominator values by address
+ */
+void xvip_bpl_scaling_factor(u32 fourcc, u32 *numerator, u32 *denominator)
+{
+   switch (fourcc) {
+   case V4L2_PIX_FMT_XV15M:
+   *numerator = 10;
+   *denominator = 8;
+   break;
+   default:
+   *numerator   = 1;
+   *denominator = 1;
+   break;
+   }
+}
+EXPORT_SYMBOL_GPL(xvip_bpl_scaling_factor);
+
+/**
+ * xvip_width_padding_factor - Retrieve width's padding factor for a 4CC
+ * @fourcc: the format 4CC
+ *
+ * Return: Return numerator and denominator values by address
+ */
+void xvip_width_padding_factor(u32 fourcc, u32 *numerator, u32 *denominator)
+{
+   switch (fourcc) {
+   case V4L2_PIX_FMT_XV15M:
+   /* 32 bits are required per 30 bits of data */
+   *numerator = 32;
+   *denominator = 30;
+   break;
+   default:
+   *numerator   = 1;
+   *denominator = 1;
+   break;
+   }
+}
+EXPORT_SYMBOL_GPL(xvip_width_padding_factor);
+
+/**
  * xvip_of_get_format - Parse a device tree node and return format information
  * @node: the device tree node
  *
diff --git a/drivers/media/platform/xilinx/xilinx-vip.h 
b/drivers/media/platform/xilinx/xilinx-vip.h
index 006dcf77..26fada7 100644
--- a/drivers/media/platform/xilinx/xilinx-vip.h
+++ b/drivers/media/platform/xilinx/xilinx-vip.h
@@ -135,6 +135,8 @@ struct xvip_video_format {
 const struct xvip_video_format *xvip_get_format_by_code(unsigned int code);
 const struct xvip_video_format *xvip_get_format_by_fourcc(u32 fourcc);
 const struct xvip_video_format *xvip_of_get_format(struct device_node *node);
+void xvip_bpl_scaling_factor(u32 fourcc, u32 *numerator, u32 *denominator);
+void xvip_width_padding_factor(u32 fourcc, u32 *numerator, u32 *denominator);
 void xvip_set_format_size(struct v4l2_mbus_framefmt *format,
  const struct v4l2_subdev_format *fmt);
 int xvip_enum_mbus_code(struct v4l2_subdev *subdev,
--
2.7.4

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.


[PATCH 2/8] media: xilinx: vip: Add the pixel format for RGB24

2018-02-07 Thread Satish Kumar Nagireddy
From: Hyun Kwon 

The pixel format for RGB24 is missing, and the driver
always falls back to YUYV as no format descriptor matches
with RGB24 fourcc. The pixel format is added to RGB24
format descriptor so that user can use the format.

Signed-off-by: Satish Kumar Nagireddy 
---
 drivers/media/platform/xilinx/xilinx-vip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/xilinx/xilinx-vip.c 
b/drivers/media/platform/xilinx/xilinx-vip.c
index 3112591..d306f44 100644
--- a/drivers/media/platform/xilinx/xilinx-vip.c
+++ b/drivers/media/platform/xilinx/xilinx-vip.c
@@ -32,7 +32,7 @@ static const struct xvip_video_format xvip_video_formats[] = {
{ XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24,
  3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" },
{ XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24,
- 3, 0, NULL },
+ 3, V4L2_PIX_FMT_RGB24, "24-bit RGB" },
{ XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8,
  1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" },
{ XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8,
--
2.7.4

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.


[PATCH 8/8] v4l: xilinx: dma: Get scaling and padding factor to calculate DMA params

2018-02-07 Thread Satish Kumar Nagireddy
Get multiplying factor to calculate bpp especially
in case of 10 bit formats.
Get multiplying factor to calculate padding width

Signed-off-by: Satish Kumar Nagireddy 
---
 drivers/media/platform/xilinx/xilinx-dma.c | 29 ++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-dma.c 
b/drivers/media/platform/xilinx/xilinx-dma.c
index 656a87e..47b22e5 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -417,6 +417,7 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb)
struct xvip_dma_buffer *buf = to_xvip_dma_buffer(vbuf);
struct dma_async_tx_descriptor *desc;
u32 flags, luma_size;
+   u32 padding_factor_nume, padding_factor_deno, bpl_nume, bpl_deno;
dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb, 0);

if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE ||
@@ -442,8 +443,15 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb)
struct v4l2_pix_format_mplane *pix_mp;

pix_mp = &dma->format.fmt.pix_mp;
+   xvip_width_padding_factor (pix_mp->pixelformat,
+  &padding_factor_nume,
+  &padding_factor_deno);
+   xvip_bpl_scaling_factor (pix_mp->pixelformat, &bpl_nume,
+&bpl_deno);
dma->xt.frame_size = dma->fmtinfo->num_planes;
-   dma->sgl[0].size = pix_mp->width * dma->fmtinfo->bpl_factor;
+   dma->sgl[0].size = (pix_mp->width * dma->fmtinfo->bpl_factor *
+  padding_factor_nume * bpl_nume)/
+  (padding_factor_deno * bpl_deno);
dma->sgl[0].icg = pix_mp->plane_fmt[0].bytesperline -
dma->sgl[0].size;
dma->xt.numf = pix_mp->height;
@@ -472,8 +480,15 @@ static void xvip_dma_buffer_queue(struct vb2_buffer *vb)
struct v4l2_pix_format *pix;

pix = &dma->format.fmt.pix;
+   xvip_width_padding_factor (pix->pixelformat,
+  &padding_factor_nume,
+  &padding_factor_deno);
+   xvip_bpl_scaling_factor (pix->pixelformat, &bpl_nume,
+&bpl_deno);
dma->xt.frame_size = dma->fmtinfo->num_planes;
-   dma->sgl[0].size = pix->width * dma->fmtinfo->bpl_factor;
+   dma->sgl[0].size = (pix->width * dma->fmtinfo->bpl_factor *
+  padding_factor_nume * bpl_nume)/
+  (padding_factor_deno * bpl_deno);
dma->sgl[0].icg = pix->bytesperline - dma->sgl[0].size;
dma->xt.numf = pix->height;
dma->sgl[0].dst_icg = dma->sgl[0].size;
@@ -682,6 +697,8 @@ __xvip_dma_try_format(struct xvip_dma *dma,
unsigned int align;
unsigned int bpl;
unsigned int i, hsub, vsub, plane_width, plane_height;
+   unsigned int padding_factor_nume, padding_factor_deno;
+   unsigned int bpl_nume, bpl_deno;

/* Retrieve format information and select the default format if the
 * requested format isn't supported.
@@ -696,6 +713,10 @@ __xvip_dma_try_format(struct xvip_dma *dma,
if (IS_ERR(info))
info = xvip_get_format_by_fourcc(XVIP_DMA_DEF_FORMAT);

+   xvip_width_padding_factor (info->fourcc, &padding_factor_nume,
+  &padding_factor_deno);
+   xvip_bpl_scaling_factor (info->fourcc, &bpl_nume, &bpl_deno);
+
/* The transfer alignment requirements are expressed in bytes. Compute
 * the minimum and maximum values, clamp the requested width and convert
 * it back to pixels.
@@ -739,7 +760,9 @@ __xvip_dma_try_format(struct xvip_dma *dma,
for (i = 0; i < info->num_planes; i++) {
plane_width = pix_mp->width / (i ? hsub : 1);
plane_height = pix_mp->height / (i ? vsub : 1);
-   min_bpl = plane_width * info->bpl_factor;
+   min_bpl = (plane_width * info->bpl_factor *
+ padding_factor_nume * bpl_nume)/
+ (padding_factor_deno * bpl_deno);
max_bpl = rounddown(XVIP_DMA_MAX_WIDTH,
dma->align);
bpl = pix_mp->plane_fmt[i].bytesperline;
--
2.7.4

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the in

[PATCH 0/8] Add support for multi-planar formats and 10 bit formats

2018-02-07 Thread Satish Kumar Nagireddy
 The patches are for xilinx v4l. The patcheset enable support to handle 
multiplanar
 formats and 10 bit formats. The implemenation has handling of single plane 
formats
 too for backward compatibility of some existing applications.

 Some patches are included as dependencies and are intended to sync downstream 
with
 upstream as well.

Hyun Kwon (1):
  media: xilinx: vip: Add the pixel format for RGB24

Jeffrey Mouroux (1):
  uapi: media: New fourcc codes needed by Xilinx Video IP

Radhey Shyam Pandey (1):
  v4l: xilinx: dma: Remove colorspace check in xvip_dma_verify_format

Rohit Athavale (1):
  media-bus: uapi: Add YCrCb 420 media bus format

Satish Kumar Nagireddy (4):
  v4l: xilinx: dma: Update video format descriptor
  v4l: xilinx: dma: Add multi-planar support
  v4l: xilinx: dma: Add scaling and padding factor functions
  v4l: xilinx: dma: Get scaling and padding factor to calculate DMA
params

 drivers/media/platform/xilinx/xilinx-dma.c  | 365 
 drivers/media/platform/xilinx/xilinx-dma.h  |   2 +-
 drivers/media/platform/xilinx/xilinx-vip.c  |  61 -
 drivers/media/platform/xilinx/xilinx-vip.h  |  13 +-
 drivers/media/platform/xilinx/xilinx-vipp.c |  22 +-
 include/uapi/linux/media-bus-format.h   |   3 +-
 include/uapi/linux/videodev2.h  |  11 +
 7 files changed, 409 insertions(+), 68 deletions(-)

--
2.7.4

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.


Re: [PATCH v8 0/7] TDA1997x HDMI video reciver

2018-02-07 Thread Hans Verkuil
On 02/07/2018 11:05 PM, Tim Harvey wrote:
> On Wed, Feb 7, 2018 at 1:09 AM, Hans Verkuil  wrote:
>> On 02/07/18 09:22, Hans Verkuil wrote:
>>> On 02/07/2018 12:29 AM, Tim Harvey wrote:
 Media Controller ioctls:
 fail: v4l2-test-media.cpp(141): ent.function ==
 MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
>>>
>>> Weird, this shouldn't happen. I'll look into this a bit more.
>>
>> Can you run 'mc_nextgen_test -e -i' and post the output?
>>
>> It's found in contrib/test.
>>
> 
> root@ventana:~# ./v4l-utils/contrib/test/mc_nextgen_test -e -i
> Device: imx-media (driver imx-media)
> Bus:
> version: 0
> number of entities: 24
> number of interfaces: 24
> number of pads: 48
> number of links: 50
> entity entity#1: 'unknown entity type' adv7180 2-0020, 1 pad(s), 1 source(s)
> entity entity#3: 'unknown entity type' tda19971 2-0048, 1 pad(s), 1 source(s)
> entity entity#5: 'unknown entity type' ipu1_vdic, 3 pad(s), 2 sink(s),
> 1 source(s)
> entity entity#9: 'unknown entity type' ipu2_vdic, 3 pad(s), 2 sink(s),
> 1 source(s)
> entity entity#13: 'unknown entity type' ipu1_ic_prp, 3 pad(s), 1
> sink(s), 2 source(s)
> entity entity#17: 'unknown entity type' ipu1_ic_prpenc, 2 pad(s), 1
> sink(s), 1 source(s)
> entity entity#20: 'V4L I/O' ipu1_ic_prpenc capture, 1 pad(s), 1 sink(s)
> entity entity#26: 'unknown entity type' ipu1_ic_prpvf, 2 pad(s), 1
> sink(s), 1 source(s)
> entity entity#29: 'V4L I/O' ipu1_ic_prpvf capture, 1 pad(s), 1 sink(s)
> entity entity#35: 'unknown entity type' ipu2_ic_prp, 3 pad(s), 1
> sink(s), 2 source(s)
> entity entity#39: 'unknown entity type' ipu2_ic_prpenc, 2 pad(s), 1
> sink(s), 1 source(s)
> entity entity#42: 'V4L I/O' ipu2_ic_prpenc capture, 1 pad(s), 1 sink(s)
> entity entity#48: 'unknown entity type' ipu2_ic_prpvf, 2 pad(s), 1
> sink(s), 1 source(s)
> entity entity#51: 'V4L I/O' ipu2_ic_prpvf capture, 1 pad(s), 1 sink(s)
> entity entity#57: 'unknown entity type' ipu1_csi0, 3 pad(s), 1
> sink(s), 2 source(s)
> entity entity#61: 'V4L I/O' ipu1_csi0 capture, 1 pad(s), 1 sink(s)
> entity entity#67: 'unknown entity type' ipu1_csi1, 3 pad(s), 1
> sink(s), 2 source(s)
> entity entity#71: 'V4L I/O' ipu1_csi1 capture, 1 pad(s), 1 sink(s)
> entity entity#77: 'unknown entity type' ipu2_csi0, 3 pad(s), 1
> sink(s), 2 source(s)
> entity entity#81: 'V4L I/O' ipu2_csi0 capture, 1 pad(s), 1 sink(s)
> entity entity#87: 'unknown entity type' ipu2_csi1, 3 pad(s), 1
> sink(s), 2 source(s)
> entity entity#91: 'V4L I/O' ipu2_csi1 capture, 1 pad(s), 1 sink(s)
> entity entity#97: 'unknown entity type' ipu1_csi0_mux, 3 pad(s), 2
> sink(s), 1 source(s)
> entity entity#101: 'unknown entity type' ipu2_csi1_mux, 3 pad(s), 2
> sink(s), 1 source(s)

Yuck. So nobody in imx (and adv7180!) is setting a valid function.
And I see the mc_nextgen_test.c doesn't know all the latest functions
anyway.

That's what happens when you don't have compliance tests, nobody bothers
to fill stuff like that in. Anyway, that explains the v4l2-compliance error
you got (although I should improve the error to also mentioned the entity
in question). In other words, it's not you, it's them :-)

Regards,

Hans

> interface intf_devnode#21: video /dev/video0
> interface intf_devnode#30: video /dev/video1
> interface intf_devnode#43: video /dev/video2
> interface intf_devnode#52: video /dev/video3
> interface intf_devnode#62: video /dev/video4
> interface intf_devnode#72: video /dev/video5
> interface intf_devnode#82: video /dev/video6
> interface intf_devnode#92: video /dev/video7
> interface intf_devnode#141: v4l2-subdev /dev/v4l-subdev0
> interface intf_devnode#143: v4l2-subdev /dev/v4l-subdev1
> interface intf_devnode#145: v4l2-subdev /dev/v4l-subdev2
> interface intf_devnode#147: v4l2-subdev /dev/v4l-subdev3
> interface intf_devnode#149: v4l2-subdev /dev/v4l-subdev4
> interface intf_devnode#151: v4l2-subdev /dev/v4l-subdev5
> interface intf_devnode#153: v4l2-subdev /dev/v4l-subdev6
> interface intf_devnode#155: v4l2-subdev /dev/v4l-subdev7
> interface intf_devnode#157: v4l2-subdev /dev/v4l-subdev8
> interface intf_devnode#159: v4l2-subdev /dev/v4l-subdev9
> interface intf_devnode#161: v4l2-subdev /dev/v4l-subdev10
> interface intf_devnode#163: v4l2-subdev /dev/v4l-subdev11
> interface intf_devnode#165: v4l2-subdev /dev/v4l-subdev12
> interface intf_devnode#167: v4l2-subdev /dev/v4l-subdev13
> interface intf_devnode#169: v4l2-subdev /dev/v4l-subdev14
> interface intf_devnode#171: v4l2-subdev /dev/v4l-subdev15
> 
> I updated v4l2-compliance and ran again:
> root@ventana:~# v4l2-compliance -m0 -M
> v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8
> Media Driver Info:
> Driver name  : imx-media
> Model: imx-media
> Serial   :
> Bus info :
> Media version: 4.15.0
> Hardware revision: 0x (0)
> Driver version   : 4.15.0
> 
> Compliance test for device /dev/media0:
> 
> Required ioctls:
> test MEDIA_IO

Re: [PATCH v8 0/7] TDA1997x HDMI video reciver

2018-02-07 Thread Tim Harvey
On Wed, Feb 7, 2018 at 1:09 AM, Hans Verkuil  wrote:
> On 02/07/18 09:22, Hans Verkuil wrote:
>> On 02/07/2018 12:29 AM, Tim Harvey wrote:
>>> Media Controller ioctls:
>>> fail: v4l2-test-media.cpp(141): ent.function ==
>>> MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
>>
>> Weird, this shouldn't happen. I'll look into this a bit more.
>
> Can you run 'mc_nextgen_test -e -i' and post the output?
>
> It's found in contrib/test.
>

root@ventana:~# ./v4l-utils/contrib/test/mc_nextgen_test -e -i
Device: imx-media (driver imx-media)
Bus:
version: 0
number of entities: 24
number of interfaces: 24
number of pads: 48
number of links: 50
entity entity#1: 'unknown entity type' adv7180 2-0020, 1 pad(s), 1 source(s)
entity entity#3: 'unknown entity type' tda19971 2-0048, 1 pad(s), 1 source(s)
entity entity#5: 'unknown entity type' ipu1_vdic, 3 pad(s), 2 sink(s),
1 source(s)
entity entity#9: 'unknown entity type' ipu2_vdic, 3 pad(s), 2 sink(s),
1 source(s)
entity entity#13: 'unknown entity type' ipu1_ic_prp, 3 pad(s), 1
sink(s), 2 source(s)
entity entity#17: 'unknown entity type' ipu1_ic_prpenc, 2 pad(s), 1
sink(s), 1 source(s)
entity entity#20: 'V4L I/O' ipu1_ic_prpenc capture, 1 pad(s), 1 sink(s)
entity entity#26: 'unknown entity type' ipu1_ic_prpvf, 2 pad(s), 1
sink(s), 1 source(s)
entity entity#29: 'V4L I/O' ipu1_ic_prpvf capture, 1 pad(s), 1 sink(s)
entity entity#35: 'unknown entity type' ipu2_ic_prp, 3 pad(s), 1
sink(s), 2 source(s)
entity entity#39: 'unknown entity type' ipu2_ic_prpenc, 2 pad(s), 1
sink(s), 1 source(s)
entity entity#42: 'V4L I/O' ipu2_ic_prpenc capture, 1 pad(s), 1 sink(s)
entity entity#48: 'unknown entity type' ipu2_ic_prpvf, 2 pad(s), 1
sink(s), 1 source(s)
entity entity#51: 'V4L I/O' ipu2_ic_prpvf capture, 1 pad(s), 1 sink(s)
entity entity#57: 'unknown entity type' ipu1_csi0, 3 pad(s), 1
sink(s), 2 source(s)
entity entity#61: 'V4L I/O' ipu1_csi0 capture, 1 pad(s), 1 sink(s)
entity entity#67: 'unknown entity type' ipu1_csi1, 3 pad(s), 1
sink(s), 2 source(s)
entity entity#71: 'V4L I/O' ipu1_csi1 capture, 1 pad(s), 1 sink(s)
entity entity#77: 'unknown entity type' ipu2_csi0, 3 pad(s), 1
sink(s), 2 source(s)
entity entity#81: 'V4L I/O' ipu2_csi0 capture, 1 pad(s), 1 sink(s)
entity entity#87: 'unknown entity type' ipu2_csi1, 3 pad(s), 1
sink(s), 2 source(s)
entity entity#91: 'V4L I/O' ipu2_csi1 capture, 1 pad(s), 1 sink(s)
entity entity#97: 'unknown entity type' ipu1_csi0_mux, 3 pad(s), 2
sink(s), 1 source(s)
entity entity#101: 'unknown entity type' ipu2_csi1_mux, 3 pad(s), 2
sink(s), 1 source(s)
interface intf_devnode#21: video /dev/video0
interface intf_devnode#30: video /dev/video1
interface intf_devnode#43: video /dev/video2
interface intf_devnode#52: video /dev/video3
interface intf_devnode#62: video /dev/video4
interface intf_devnode#72: video /dev/video5
interface intf_devnode#82: video /dev/video6
interface intf_devnode#92: video /dev/video7
interface intf_devnode#141: v4l2-subdev /dev/v4l-subdev0
interface intf_devnode#143: v4l2-subdev /dev/v4l-subdev1
interface intf_devnode#145: v4l2-subdev /dev/v4l-subdev2
interface intf_devnode#147: v4l2-subdev /dev/v4l-subdev3
interface intf_devnode#149: v4l2-subdev /dev/v4l-subdev4
interface intf_devnode#151: v4l2-subdev /dev/v4l-subdev5
interface intf_devnode#153: v4l2-subdev /dev/v4l-subdev6
interface intf_devnode#155: v4l2-subdev /dev/v4l-subdev7
interface intf_devnode#157: v4l2-subdev /dev/v4l-subdev8
interface intf_devnode#159: v4l2-subdev /dev/v4l-subdev9
interface intf_devnode#161: v4l2-subdev /dev/v4l-subdev10
interface intf_devnode#163: v4l2-subdev /dev/v4l-subdev11
interface intf_devnode#165: v4l2-subdev /dev/v4l-subdev12
interface intf_devnode#167: v4l2-subdev /dev/v4l-subdev13
interface intf_devnode#169: v4l2-subdev /dev/v4l-subdev14
interface intf_devnode#171: v4l2-subdev /dev/v4l-subdev15

I updated v4l2-compliance and ran again:
root@ventana:~# v4l2-compliance -m0 -M
v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8
Media Driver Info:
Driver name  : imx-media
Model: imx-media
Serial   :
Bus info :
Media version: 4.15.0
Hardware revision: 0x (0)
Driver version   : 4.15.0

Compliance test for device /dev/media0:

Required ioctls:
test MEDIA_IOC_DEVICE_INFO: OK

Allow for multiple opens:
test second /dev/media0 open: OK
test MEDIA_IOC_DEVICE_INFO: OK
test for unlimited opens: OK

Media Controller ioctls:
fail: v4l2-test-media.cpp(94): function ==
MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
fail: v4l2-test-media.cpp(156):
checkFunction(ent.function, true)
test MEDIA_IOC_G_TOPOLOGY: FAIL
fail: v4l2-test-media.cpp(275): num_data_links != num_links
test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL
test MEDIA_IOC_SETUP_LINK: OK

Total: 7, Succeeded: 5, Failed: 2, Warnings: 0

Regards,

Tim


Re: [PATCH v3 4/8] i2c: ov9650: use 64-bit arithmetic instead of 32-bit

2018-02-07 Thread Sakari Ailus
Hi Gustavo,

On Tue, Feb 06, 2018 at 10:47:50AM -0600, Gustavo A. R. Silva wrote:
> Add suffix ULL to constants 1 and 100 in order to give the
> compiler complete information about the proper arithmetic to use.
> Notice that these constants are used in contexts that expect
> expressions of type u64 (64 bits, unsigned).
> 
> The following expressions:
> 
> (u64)(fi->interval.numerator * 1)
> (u64)(iv->interval.numerator * 1)
> fiv->interval.numerator * 100 / fiv->interval.denominator
> 
> are currently being evaluated using 32-bit arithmetic.
> 
> Notice that those casts to u64 for the first two expressions are only
> effective after such expressions are evaluated using 32-bit arithmetic,
> which leads to potential integer overflows. So based on those casts, it
> seems that the original intention of the code is to actually use 64-bit
> arithmetic instead of 32-bit.
> 
> Also, notice that once the suffix ULL is added to the constants, the
> outer casts to u64 are no longer needed.
> 
> Addresses-Coverity-ID: 1324146 ("Unintentional integer overflow")
> Fixes: 84a15ded76ec ("[media] V4L: Add driver for OV9650/52 image sensors")
> Fixes: 79211c8ed19c ("remove abs64()")
> Signed-off-by: Gustavo A. R. Silva 
> ---
> Changes in v2:
>  - Update subject and changelog to better reflect the proposed code changes.
>  - Add suffix ULL to constants instead of casting variables.
>  - Remove unnecessary casts to u64 as part of the code change.
>  - Extend the same code change to other similar expressions.
> 
> Changes in v3:
>  - None.
> 
>  drivers/media/i2c/ov9650.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
> index e519f27..e716e98 100644
> --- a/drivers/media/i2c/ov9650.c
> +++ b/drivers/media/i2c/ov9650.c
> @@ -1130,7 +1130,7 @@ static int __ov965x_set_frame_interval(struct ov965x 
> *ov965x,
>   if (fi->interval.denominator == 0)
>   return -EINVAL;
>  
> - req_int = (u64)(fi->interval.numerator * 1) /
> + req_int = fi->interval.numerator * 1ULL /
>   fi->interval.denominator;

This has been addressed by your earlier patch "i2c: ov9650: fix potential 
integer overflow in
__ov965x_set_frame_interval" I tweaked a little. It's not in media tree
master yet.

>  
>   for (i = 0; i < ARRAY_SIZE(ov965x_intervals); i++) {
> @@ -1139,7 +1139,7 @@ static int __ov965x_set_frame_interval(struct ov965x 
> *ov965x,
>   if (mbus_fmt->width != iv->size.width ||
>   mbus_fmt->height != iv->size.height)
>   continue;
> - err = abs((u64)(iv->interval.numerator * 1) /
> + err = abs(iv->interval.numerator * 1ULL /

This and the chunk below won't work on e.g. 32-bit ARM. do_div(), please.

>   iv->interval.denominator - req_int);
>   if (err < min_err) {
>   fiv = iv;
> @@ -1148,8 +1148,9 @@ static int __ov965x_set_frame_interval(struct ov965x 
> *ov965x,
>   }
>   ov965x->fiv = fiv;
>  
> - v4l2_dbg(1, debug, &ov965x->sd, "Changed frame interval to %u us\n",
> -  fiv->interval.numerator * 100 / fiv->interval.denominator);
> + v4l2_dbg(1, debug, &ov965x->sd, "Changed frame interval to %llu us\n",
> +  fiv->interval.numerator * 100ULL /
> +  fiv->interval.denominator);
>  
>   return 0;
>  }

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH 2/2] drm: adv7511: Add support for i2c_new_secondary_device

2018-02-07 Thread Laurent Pinchart
Hi Kieran,

On Wednesday, 7 February 2018 17:14:09 EET Kieran Bingham wrote:
> On 29/01/18 10:26, Laurent Pinchart wrote:
> > On Monday, 22 January 2018 14:50:00 EET Kieran Bingham wrote:
> >> The ADV7511 has four 256-byte maps that can be accessed via the main I²C
> >> ports. Each map has it own I²C address and acts as a standard slave
> >> device on the I²C bus.
> >> 
> >> Allow a device tree node to override the default addresses so that
> >> address conflicts with other devices on the same bus may be resolved at
> >> the board description level.
> >> 
> >> Signed-off-by: Kieran Bingham 
> >> ---
> >> 
> >>  .../bindings/display/bridge/adi,adv7511.txt| 10 +-
> > 
> > I don't mind personally, but device tree maintainers usually ask for DT
> > bindings changes to be split to a separate patch.
> > 
> >>  drivers/gpu/drm/bridge/adv7511/adv7511.h   |  4 +++
> >>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c   | 36 ++-
> >>  3 files changed, 37 insertions(+), 13 deletions(-)
> >> 
> >> diff --git
> >> a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
> >> b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
> >> index 0047b1394c70..f6bb9f6d3f48 100644
> >> --- a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
> >> +++ b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
> >> 
> >> @@ -70,6 +70,9 @@ Optional properties:
> >>rather than generate its own timings for HDMI output.
> >>  
> >>  - clocks: from common clock binding: reference to the CEC clock.
> >>  - clock-names: from common clock binding: must be "cec".
> >> 
> >> +- reg-names : Names of maps with programmable addresses.
> >> +  It can contain any map needing a non-default address.
> >> +  Possible maps names are : "main", "edid", "cec", "packet"
> > 
> > Is the reg-names property (and the additional maps) mandatory or optional
> > ? If mandatory you should also update the existing DT sources that use
> > those bindings.
> 
> They are currently optional. I do prefer it that way - but perhaps due to an
> issue mentioned below we might need to make this driver mandatory ?
> 
> > If optional you should define which I2C addresses will be used when
> > the maps are not specified (and in that case I think we should go for
> > the addresses listed as default in the datasheet, which correspond to the
> > current driver implementation when the main address is 0x3d/0x7a).
> 
> The current addresses do not correspond to the datasheet, even when the
> implementation main address is set to 0x3d.

Don't they ? The driver currently uses the following (8-bit) I2C addresses:

EDID:   main + 4  = 0x7e (0x3f)
Packet: main - 10 = 0x70 (0x38)
CEC:main - 2  = 0x78 (0x3c)

Those are the default addresses according to section 4.1 of the ADV7511W 
programming guide (rev. B), and they match the ones you set in this patch.

> Thus, in my opinion - they are currently 'wrong' - but perhaps changing them
> is considered breakage too.
> 
> A particular issue will arise here too - as on this device - when the device
> is in low-power mode (after probe, before use) - the maps will respond on
> their *hardware default* addresses (the ones implemented in this patch),
> and thus consume that address on the I2C bus regardless of their settings
> in the driver.

We've discussed this previously and I share you concern. Just to make sure I 
remember correctly, did all the secondary maps reset to their default 
addresses, or just the EDID map ?

> > You should also update the definition of the reg property that currently
> > just states
> > 
> > - reg: I2C slave address
> > 
> > And finally you might want to define the term "map" in this context.
> > Here's a proposal (if we make all maps mandatory).
> > 
> > The ADV7511 internal registers are split into four pages exposed through
> > different I2C addresses, creating four register maps. The I2C addresses of
> > all four maps shall be specified by the reg and reg-names property.
> > 
> > - reg: I2C slave addresses, one per reg-names entry
> > - reg-names: map names, shall be "main", "edid", "cec", "packet"
> > 
> >>  Required nodes:
> >> @@ -88,7 +91,12 @@ Example
> >> 
> >>adv7511w: hdmi@39 {
> >>compatible = "adi,adv7511w";
> >> -  reg = <39>;
> >> +  /*
> >> +   * The EDID page will be accessible on address 0x66 on the i2c
> >> +   * bus. All other maps continue to use their default addresses.
> >> +   */
> >> +  reg = <0x39 0x66>;
> >> +  reg-names = "main", "edid";
> >>interrupt-parent = <&gpio3>;
> >>interrupts = <29 IRQ_TYPE_EDGE_FALLING>;
> >>clocks = <&cec_clock>;

[snip]

> >> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> >> b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> >> index efa29db5fc2b..7ec33837752b 100644
> >> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> >> +++ b/drivers/gpu/drm/bridge/a

[PATCH] media: i2c: adv748x: Fix cleanup jump on chip identification

2018-02-07 Thread Kieran Bingham
From: Kieran Bingham 

The error handling for the adv748x_identify_chip() call erroneously
jumps to the err_cleanup_clients label before the clients have been
established.

Correct this by jumping to the next (and correct) label in the cleanup
code: err_cleanup_dt.

Fixes: 3e89586a64df ("media: i2c: adv748x: add adv748x driver")

Signed-off-by: Kieran Bingham 
---
 drivers/media/i2c/adv748x/adv748x-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv748x/adv748x-core.c 
b/drivers/media/i2c/adv748x/adv748x-core.c
index 6d62b817ed00..6ccaad7e9eca 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -651,7 +651,7 @@ static int adv748x_probe(struct i2c_client *client,
ret = adv748x_identify_chip(state);
if (ret) {
adv_err(state, "Failed to identify chip");
-   goto err_cleanup_clients;
+   goto err_cleanup_dt;
}
 
/* Configure remaining pages as I2C clients with regmap access */
-- 
2.7.4



Re: [PATCH] media: stm32-dcmi: add g/s_parm framerate support

2018-02-07 Thread Hans Verkuil
On 02/07/2018 06:43 PM, Hugues Fruchet wrote:
> Add g/s_parm framerate support by calling subdev
> g/s_frame_interval ops.
> This allows user to control sensor framerate by
> calling ioctl G/S_PARM.
> 
> Signed-off-by: Hugues Fruchet 
> ---
>  drivers/media/platform/stm32/stm32-dcmi.c | 49 
> +++
>  1 file changed, 49 insertions(+)
> 
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c 
> b/drivers/media/platform/stm32/stm32-dcmi.c
> index ab555d4..8197554 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1151,6 +1151,52 @@ static int dcmi_enum_framesizes(struct file *file, 
> void *fh,
>   return 0;
>  }
>  
> +static int dcmi_g_parm(struct file *file, void *priv,
> +struct v4l2_streamparm *p)
> +{
> + struct stm32_dcmi *dcmi = video_drvdata(file);
> + struct v4l2_subdev_frame_interval ival = { 0 };
> + int ret;
> +
> + if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> + return -EINVAL;
> +
> + p->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
> + ret = v4l2_subdev_call(dcmi->entity.subdev, video,
> +g_frame_interval, &ival);
> + if (ret)
> + return ret;
> +
> + p->parm.capture.timeperframe = ival.interval;
> +
> + return ret;
> +}

This function and the next can be simplified by using the help functions
introduced here:

https://git.linuxtv.org/hverkuil/media_tree.git/log/?h=parm

I'll make a pull request for this later this week, so it's probably a good
idea to base your code on this as well.

Regards,

Hans

> +
> +static int dcmi_s_parm(struct file *file, void *priv,
> +struct v4l2_streamparm *p)
> +{
> + struct stm32_dcmi *dcmi = video_drvdata(file);
> + struct v4l2_subdev_frame_interval ival = {
> + 0,
> + p->parm.capture.timeperframe
> + };
> + int ret;
> +
> + if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> + return -EINVAL;
> +
> + memset(&p->parm, 0, sizeof(p->parm));
> + p->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
> + ret = v4l2_subdev_call(dcmi->entity.subdev, video,
> +s_frame_interval, &ival);
> + if (ret)
> + return ret;
> +
> + p->parm.capture.timeperframe = ival.interval;
> +
> + return ret;
> +}
> +
>  static int dcmi_enum_frameintervals(struct file *file, void *fh,
>   struct v4l2_frmivalenum *fival)
>  {
> @@ -1253,6 +1299,9 @@ static int dcmi_release(struct file *file)
>   .vidioc_g_input = dcmi_g_input,
>   .vidioc_s_input = dcmi_s_input,
>  
> + .vidioc_g_parm  = dcmi_g_parm,
> + .vidioc_s_parm  = dcmi_s_parm,
> +
>   .vidioc_enum_framesizes = dcmi_enum_framesizes,
>   .vidioc_enum_frameintervals = dcmi_enum_frameintervals,
>  
> 



[PATCH] media: stm32-dcmi: add g/s_parm framerate support

2018-02-07 Thread Hugues Fruchet
Add g/s_parm framerate support by calling subdev
g/s_frame_interval ops.
This allows user to control sensor framerate by
calling ioctl G/S_PARM.

Signed-off-by: Hugues Fruchet 
---
 drivers/media/platform/stm32/stm32-dcmi.c | 49 +++
 1 file changed, 49 insertions(+)

diff --git a/drivers/media/platform/stm32/stm32-dcmi.c 
b/drivers/media/platform/stm32/stm32-dcmi.c
index ab555d4..8197554 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1151,6 +1151,52 @@ static int dcmi_enum_framesizes(struct file *file, void 
*fh,
return 0;
 }
 
+static int dcmi_g_parm(struct file *file, void *priv,
+  struct v4l2_streamparm *p)
+{
+   struct stm32_dcmi *dcmi = video_drvdata(file);
+   struct v4l2_subdev_frame_interval ival = { 0 };
+   int ret;
+
+   if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   return -EINVAL;
+
+   p->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
+   ret = v4l2_subdev_call(dcmi->entity.subdev, video,
+  g_frame_interval, &ival);
+   if (ret)
+   return ret;
+
+   p->parm.capture.timeperframe = ival.interval;
+
+   return ret;
+}
+
+static int dcmi_s_parm(struct file *file, void *priv,
+  struct v4l2_streamparm *p)
+{
+   struct stm32_dcmi *dcmi = video_drvdata(file);
+   struct v4l2_subdev_frame_interval ival = {
+   0,
+   p->parm.capture.timeperframe
+   };
+   int ret;
+
+   if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   return -EINVAL;
+
+   memset(&p->parm, 0, sizeof(p->parm));
+   p->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
+   ret = v4l2_subdev_call(dcmi->entity.subdev, video,
+  s_frame_interval, &ival);
+   if (ret)
+   return ret;
+
+   p->parm.capture.timeperframe = ival.interval;
+
+   return ret;
+}
+
 static int dcmi_enum_frameintervals(struct file *file, void *fh,
struct v4l2_frmivalenum *fival)
 {
@@ -1253,6 +1299,9 @@ static int dcmi_release(struct file *file)
.vidioc_g_input = dcmi_g_input,
.vidioc_s_input = dcmi_s_input,
 
+   .vidioc_g_parm  = dcmi_g_parm,
+   .vidioc_s_parm  = dcmi_s_parm,
+
.vidioc_enum_framesizes = dcmi_enum_framesizes,
.vidioc_enum_frameintervals = dcmi_enum_frameintervals,
 
-- 
1.9.1



[PATCH] media: stm32-dcmi: rework overrun/error case

2018-02-07 Thread Hugues Fruchet
Do not stop/restart dma on overrun or errors.
Dma will be restarted on current frame transfer
completion. Frame transfer completion is ensured
even if overrun or error occurs by DCMI continuous
capture mode which restarts data transfer at next
frame sync.
Do no warn on overrun while in irq thread, this slows down
system and lead to more overrun errors. Use a counter
instead and log errors at stop streaming.

Signed-off-by: Hugues Fruchet 
---
 drivers/media/platform/stm32/stm32-dcmi.c | 30 --
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/media/platform/stm32/stm32-dcmi.c 
b/drivers/media/platform/stm32/stm32-dcmi.c
index 4a75756..ab555d4 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -160,6 +160,7 @@ struct stm32_dcmi {
dma_cookie_tdma_cookie;
u32 misr;
int errors_count;
+   int overrun_count;
int buffers_count;
 };
 
@@ -373,23 +374,9 @@ static irqreturn_t dcmi_irq_thread(int irq, void *arg)
}
 
if ((dcmi->misr & IT_OVR) || (dcmi->misr & IT_ERR)) {
-   /*
-* An overflow or an error has been detected,
-* stop current DMA transfert & restart it
-*/
-   dev_warn(dcmi->dev, "%s: Overflow or error detected\n",
-__func__);
-
dcmi->errors_count++;
-   dev_dbg(dcmi->dev, "Restarting capture after DCMI error\n");
-
-   spin_unlock_irq(&dcmi->irqlock);
-   dmaengine_terminate_all(dcmi->dma_chan);
-
-   if (dcmi_start_capture(dcmi))
-   dev_err(dcmi->dev, "%s: Cannot restart capture on 
overflow or error\n",
-   __func__);
-   return IRQ_HANDLED;
+   if (dcmi->misr & IT_OVR)
+   dcmi->overrun_count++;
}
 
spin_unlock_irq(&dcmi->irqlock);
@@ -574,6 +561,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, 
unsigned int count)
 
dcmi->sequence = 0;
dcmi->errors_count = 0;
+   dcmi->overrun_count = 0;
dcmi->buffers_count = 0;
dcmi->active = NULL;
 
@@ -684,8 +672,14 @@ static void dcmi_stop_streaming(struct vb2_queue *vq)
 
clk_disable(dcmi->mclk);
 
-   dev_dbg(dcmi->dev, "Stop streaming, errors=%d buffers=%d\n",
-   dcmi->errors_count, dcmi->buffers_count);
+   if (dcmi->errors_count)
+   dev_warn(dcmi->dev, "Some errors found while streaming: 
errors=%d (overrun=%d), buffers=%d\n",
+dcmi->errors_count, dcmi->overrun_count,
+dcmi->buffers_count);
+   dev_dbg(dcmi->dev, "Stop streaming, errors=%d (overrun=%d), 
buffers=%d\n",
+   dcmi->errors_count, dcmi->overrun_count,
+   dcmi->buffers_count);
+
 }
 
 static const struct vb2_ops dcmi_video_qops = {
-- 
1.9.1



[PATCH] media: stm32-dcmi: fix lock scheme

2018-02-07 Thread Hugues Fruchet
Fix lock scheme leading to spurious freeze.

Signed-off-by: Hugues Fruchet 
---
 drivers/media/platform/stm32/stm32-dcmi.c | 57 ++-
 1 file changed, 25 insertions(+), 32 deletions(-)

diff --git a/drivers/media/platform/stm32/stm32-dcmi.c 
b/drivers/media/platform/stm32/stm32-dcmi.c
index 2fd8bed..4a75756 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -197,7 +197,7 @@ static void dcmi_dma_callback(void *param)
struct dma_tx_state state;
enum dma_status status;
 
-   spin_lock(&dcmi->irqlock);
+   spin_lock_irq(&dcmi->irqlock);
 
/* Check DMA status */
status = dmaengine_tx_status(chan, dcmi->dma_cookie, &state);
@@ -239,7 +239,7 @@ static void dcmi_dma_callback(void *param)
dcmi->errors_count++;
dcmi->active = NULL;
 
-   spin_unlock(&dcmi->irqlock);
+   spin_unlock_irq(&dcmi->irqlock);
return;
}
 
@@ -248,13 +248,11 @@ static void dcmi_dma_callback(void *param)
 
list_del_init(&dcmi->active->list);
 
-   if (dcmi_start_capture(dcmi)) {
+   spin_unlock_irq(&dcmi->irqlock);
+   if (dcmi_start_capture(dcmi))
dev_err(dcmi->dev, "%s: Cannot restart capture 
on DMA complete\n",
__func__);
-
-   spin_unlock(&dcmi->irqlock);
-   return;
-   }
+   return;
}
 
break;
@@ -263,7 +261,7 @@ static void dcmi_dma_callback(void *param)
break;
}
 
-   spin_unlock(&dcmi->irqlock);
+   spin_unlock_irq(&dcmi->irqlock);
 }
 
 static int dcmi_start_dma(struct stm32_dcmi *dcmi,
@@ -360,7 +358,7 @@ static irqreturn_t dcmi_irq_thread(int irq, void *arg)
 {
struct stm32_dcmi *dcmi = arg;
 
-   spin_lock(&dcmi->irqlock);
+   spin_lock_irq(&dcmi->irqlock);
 
/* Stop capture is required */
if (dcmi->state == STOPPING) {
@@ -370,7 +368,7 @@ static irqreturn_t dcmi_irq_thread(int irq, void *arg)
 
complete(&dcmi->complete);
 
-   spin_unlock(&dcmi->irqlock);
+   spin_unlock_irq(&dcmi->irqlock);
return IRQ_HANDLED;
}
 
@@ -383,35 +381,34 @@ static irqreturn_t dcmi_irq_thread(int irq, void *arg)
 __func__);
 
dcmi->errors_count++;
-   dmaengine_terminate_all(dcmi->dma_chan);
-
dev_dbg(dcmi->dev, "Restarting capture after DCMI error\n");
 
-   if (dcmi_start_capture(dcmi)) {
+   spin_unlock_irq(&dcmi->irqlock);
+   dmaengine_terminate_all(dcmi->dma_chan);
+
+   if (dcmi_start_capture(dcmi))
dev_err(dcmi->dev, "%s: Cannot restart capture on 
overflow or error\n",
__func__);
-
-   spin_unlock(&dcmi->irqlock);
-   return IRQ_HANDLED;
-   }
+   return IRQ_HANDLED;
}
 
-   spin_unlock(&dcmi->irqlock);
+   spin_unlock_irq(&dcmi->irqlock);
return IRQ_HANDLED;
 }
 
 static irqreturn_t dcmi_irq_callback(int irq, void *arg)
 {
struct stm32_dcmi *dcmi = arg;
+   unsigned long flags;
 
-   spin_lock(&dcmi->irqlock);
+   spin_lock_irqsave(&dcmi->irqlock, flags);
 
dcmi->misr = reg_read(dcmi->regs, DCMI_MIS);
 
/* Clear interrupt */
reg_set(dcmi->regs, DCMI_ICR, IT_FRAME | IT_OVR | IT_ERR);
 
-   spin_unlock(&dcmi->irqlock);
+   spin_unlock_irqrestore(&dcmi->irqlock, flags);
 
return IRQ_WAKE_THREAD;
 }
@@ -490,9 +487,8 @@ static void dcmi_buf_queue(struct vb2_buffer *vb)
struct stm32_dcmi *dcmi =  vb2_get_drv_priv(vb->vb2_queue);
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
struct dcmi_buf *buf = container_of(vbuf, struct dcmi_buf, vb);
-   unsigned long flags = 0;
 
-   spin_lock_irqsave(&dcmi->irqlock, flags);
+   spin_lock_irq(&dcmi->irqlock);
 
if ((dcmi->state == RUNNING) && (!dcmi->active)) {
dcmi->active = buf;
@@ -500,19 +496,17 @@ static void dcmi_buf_queue(struct vb2_buffer *vb)
dev_dbg(dcmi->dev, "Starting capture on buffer[%d] queued\n",
buf->vb.vb2_buf.index);
 
-   if (dcmi_start_capture(dcmi)) {
+   spin_unlock_irq(&dcmi->irqlock);
+   if (dcmi_start_capture(dcmi))
dev_err(dcmi->dev, "%s: Cannot restart capture on 
overflow or error\n",
__func__);
-
-   spin_unlock_irqrestore(&dcmi->irqlock, flags);
-

[PATCH v1 0/3] STM32 DCMI redundant code & trace cleanup

2018-02-07 Thread Hugues Fruchet
Remove some redundant code and fix/enhance some
error trace points.

Hugues Fruchet (3):
  media: stm32-dcmi: remove redundant capture enable
  media: stm32-dcmi: remove redundant clear of interrupt flags
  media: stm32-dcmi: improve error trace points

 drivers/media/platform/stm32/stm32-dcmi.c | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

-- 
1.9.1



[PATCH v1 2/3] media: stm32-dcmi: remove redundant clear of interrupt flags

2018-02-07 Thread Hugues Fruchet
It is already cleared in dcmi_irq_callback().

Signed-off-by: Hugues Fruchet 
---
 drivers/media/platform/stm32/stm32-dcmi.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/platform/stm32/stm32-dcmi.c 
b/drivers/media/platform/stm32/stm32-dcmi.c
index abc79d8..dfab867 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -385,8 +385,6 @@ static irqreturn_t dcmi_irq_thread(int irq, void *arg)
dcmi->errors_count++;
dmaengine_terminate_all(dcmi->dma_chan);
 
-   reg_set(dcmi->regs, DCMI_ICR, IT_FRAME | IT_OVR | IT_ERR);
-
dev_dbg(dcmi->dev, "Restarting capture after DCMI error\n");
 
if (dcmi_start_capture(dcmi)) {
-- 
1.9.1



[PATCH v1 3/3] media: stm32-dcmi: improve error trace points

2018-02-07 Thread Hugues Fruchet
Fix some missing "\n".
Trace error returned by subdev streamon/streamoff.
Remove extra "0x" unneeded with %pad formatter.

Signed-off-by: Hugues Fruchet 
---
 drivers/media/platform/stm32/stm32-dcmi.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/stm32/stm32-dcmi.c 
b/drivers/media/platform/stm32/stm32-dcmi.c
index dfab867..2fd8bed 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -234,7 +234,7 @@ static void dcmi_dma_callback(void *param)
/* Restart a new DMA transfer with next buffer */
if (dcmi->state == RUNNING) {
if (list_empty(&dcmi->buffers)) {
-   dev_err(dcmi->dev, "%s: No more buffer queued, 
cannot capture buffer",
+   dev_err(dcmi->dev, "%s: No more buffer queued, 
cannot capture buffer\n",
__func__);
dcmi->errors_count++;
dcmi->active = NULL;
@@ -249,7 +249,7 @@ static void dcmi_dma_callback(void *param)
list_del_init(&dcmi->active->list);
 
if (dcmi_start_capture(dcmi)) {
-   dev_err(dcmi->dev, "%s: Cannot restart capture 
on DMA complete",
+   dev_err(dcmi->dev, "%s: Cannot restart capture 
on DMA complete\n",
__func__);
 
spin_unlock(&dcmi->irqlock);
@@ -478,7 +478,7 @@ static int dcmi_buf_prepare(struct vb2_buffer *vb)
 
vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->size);
 
-   dev_dbg(dcmi->dev, "buffer[%d] phy=0x%pad size=%zu\n",
+   dev_dbg(dcmi->dev, "buffer[%d] phy=%pad size=%zu\n",
vb->index, &buf->paddr, buf->size);
}
 
@@ -524,7 +524,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, 
unsigned int count)
 
ret = clk_enable(dcmi->mclk);
if (ret) {
-   dev_err(dcmi->dev, "%s: Failed to start streaming, cannot 
enable clock",
+   dev_err(dcmi->dev, "%s: Failed to start streaming, cannot 
enable clock\n",
__func__);
goto err_release_buffers;
}
@@ -600,7 +600,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, 
unsigned int count)
 
ret = dcmi_start_capture(dcmi);
if (ret) {
-   dev_err(dcmi->dev, "%s: Start streaming failed, cannot start 
capture",
+   dev_err(dcmi->dev, "%s: Start streaming failed, cannot start 
capture\n",
__func__);
 
spin_unlock_irq(&dcmi->irqlock);
@@ -651,7 +651,8 @@ static void dcmi_stop_streaming(struct vb2_queue *vq)
/* Disable stream on the sub device */
ret = v4l2_subdev_call(dcmi->entity.subdev, video, s_stream, 0);
if (ret && ret != -ENOIOCTLCMD)
-   dev_err(dcmi->dev, "stream off failed in subdev\n");
+   dev_err(dcmi->dev, "%s: Failed to stop streaming, subdev 
streamoff error (%d)\n",
+   __func__, ret);
 
dcmi->state = STOPPING;
 
@@ -667,7 +668,8 @@ static void dcmi_stop_streaming(struct vb2_queue *vq)
reg_clear(dcmi->regs, DCMI_CR, CR_ENABLE);
 
if (!timeout) {
-   dev_err(dcmi->dev, "Timeout during stop streaming\n");
+   dev_err(dcmi->dev, "%s: Timeout during stop streaming\n",
+   __func__);
dcmi->state = STOPPED;
}
 
-- 
1.9.1



[PATCH v1 1/3] media: stm32-dcmi: remove redundant capture enable

2018-02-07 Thread Hugues Fruchet
Remove redundant capture enable already done
in dcmi_start_capture().

Signed-off-by: Hugues Fruchet 
---
 drivers/media/platform/stm32/stm32-dcmi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/media/platform/stm32/stm32-dcmi.c 
b/drivers/media/platform/stm32/stm32-dcmi.c
index 9460b30..abc79d8 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -255,9 +255,6 @@ static void dcmi_dma_callback(void *param)
spin_unlock(&dcmi->irqlock);
return;
}
-
-   /* Enable capture */
-   reg_set(dcmi->regs, DCMI_CR, CR_CAPTURE);
}
 
break;
-- 
1.9.1



[PATCH 1/2] media: i2c: adv748x: Simplify regmap configuration

2018-02-07 Thread Kieran Bingham
From: Kieran Bingham 

The ADV748x has identical map configurations for each register map. The
duplication of each map can be simplified using a helper macro such that
each map is represented on a single line.

Define ADV748X_REGMAP_CONF for this purpose and un-define after it's
use.

Signed-off-by: Kieran Bingham 
---
 drivers/media/i2c/adv748x/adv748x-core.c | 111 ++-
 1 file changed, 22 insertions(+), 89 deletions(-)

diff --git a/drivers/media/i2c/adv748x/adv748x-core.c 
b/drivers/media/i2c/adv748x/adv748x-core.c
index fd92c9e4b519..71c69b816db2 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -35,98 +35,31 @@
  * Register manipulation
  */
 
-static const struct regmap_config adv748x_regmap_cnf[] = {
-   {
-   .name   = "io",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-   {
-   .name   = "dpll",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-   {
-   .name   = "cp",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-   {
-   .name   = "hdmi",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-   {
-   .name   = "edid",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-   {
-   .name   = "repeater",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-   {
-   .name   = "infoframe",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-   {
-   .name   = "cec",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-   {
-   .name   = "sdp",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-
-   {
-   .name   = "txb",
-   .reg_bits   = 8,
-   .val_bits   = 8,
-
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
-   {
-   .name   = "txa",
-   .reg_bits   = 8,
-   .val_bits   = 8,
+#define ADV748X_REGMAP_CONF(n) \
+{ \
+   .name = n, \
+   .reg_bits = 8, \
+   .val_bits = 8, \
+   .max_register = 0xff, \
+   .cache_type = REGCACHE_NONE, \
+}
 
-   .max_register   = 0xff,
-   .cache_type = REGCACHE_NONE,
-   },
+static const struct regmap_config adv748x_regmap_cnf[] = {
+   ADV748X_REGMAP_CONF("io"),
+   ADV748X_REGMAP_CONF("dpll"),
+   ADV748X_REGMAP_CONF("cp"),
+   ADV748X_REGMAP_CONF("hdmi"),
+   ADV748X_REGMAP_CONF("edid"),
+   ADV748X_REGMAP_CONF("repeater"),
+   ADV748X_REGMAP_CONF("infoframe"),
+   ADV748X_REGMAP_CONF("cec"),
+   ADV748X_REGMAP_CONF("sdp"),
+   ADV748X_REGMAP_CONF("txa"),
+   ADV748X_REGMAP_CONF("txb"),
 };
 
+#undef ADV748X_REGMAP_CONF
+
 static int adv748x_configure_regmap(struct adv748x_state *state, int region)
 {
int err;
-- 
2.7.4



[PATCH 2/2] media: i2c: adv748x: Add missing CBUS page.

2018-02-07 Thread Kieran Bingham
From: Kieran Bingham 

The ADV748x has 12 pages mapped onto I2C addresses.

In the existing implementation only 11 are mapped correctly in the page
enumerations, which causes an off-by-one fault on pages above the
infoframe definition due to a missing 'CBUS' page.

This causes the address for the CEC, SDP, TXA, and TXB to be incorrectly
programmed during the iterations in adv748x_initialise_clients().

Until now this has gone un-noticed due to the fact that following the
creation of the clients - the device is reset and the addresses are
reprogrammed in manually by the call to "adv748x_write_regs(state,
adv748x_set_slave_address);"

As part of moving to dynamic i2c address allocations repair this by
providing the missing CBUS page definition.

Signed-off-by: Kieran Bingham 
---
 drivers/media/i2c/adv748x/adv748x-core.c | 3 +++
 drivers/media/i2c/adv748x/adv748x.h  | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/media/i2c/adv748x/adv748x-core.c 
b/drivers/media/i2c/adv748x/adv748x-core.c
index 71c69b816db2..6d62b817ed00 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -52,6 +52,7 @@ static const struct regmap_config adv748x_regmap_cnf[] = {
ADV748X_REGMAP_CONF("edid"),
ADV748X_REGMAP_CONF("repeater"),
ADV748X_REGMAP_CONF("infoframe"),
+   ADV748X_REGMAP_CONF("cbus"),
ADV748X_REGMAP_CONF("cec"),
ADV748X_REGMAP_CONF("sdp"),
ADV748X_REGMAP_CONF("txa"),
@@ -91,6 +92,7 @@ static int adv748x_i2c_addresses[ADV748X_PAGE_MAX] = {
ADV748X_I2C_EDID,
ADV748X_I2C_REPEATER,
ADV748X_I2C_INFOFRAME,
+   ADV748X_I2C_CBUS,
ADV748X_I2C_CEC,
ADV748X_I2C_SDP,
ADV748X_I2C_TXB,
@@ -354,6 +356,7 @@ static const struct adv748x_reg_value 
adv748x_set_slave_address[] = {
{ADV748X_PAGE_IO, 0xf6, ADV748X_I2C_EDID << 1},
{ADV748X_PAGE_IO, 0xf7, ADV748X_I2C_REPEATER << 1},
{ADV748X_PAGE_IO, 0xf8, ADV748X_I2C_INFOFRAME << 1},
+   {ADV748X_PAGE_IO, 0xf9, ADV748X_I2C_CBUS << 1},
{ADV748X_PAGE_IO, 0xfa, ADV748X_I2C_CEC << 1},
{ADV748X_PAGE_IO, 0xfb, ADV748X_I2C_SDP << 1},
{ADV748X_PAGE_IO, 0xfc, ADV748X_I2C_TXB << 1},
diff --git a/drivers/media/i2c/adv748x/adv748x.h 
b/drivers/media/i2c/adv748x/adv748x.h
index 6789e2f3bc8c..725662edc4b8 100644
--- a/drivers/media/i2c/adv748x/adv748x.h
+++ b/drivers/media/i2c/adv748x/adv748x.h
@@ -35,6 +35,7 @@
 #define ADV748X_I2C_EDID   0x36/* EDID Map */
 #define ADV748X_I2C_REPEATER   0x32/* HDMI RX Repeater Map */
 #define ADV748X_I2C_INFOFRAME  0x31/* HDMI RX InfoFrame Map */
+#define ADV748X_I2C_CBUS   0x30/* CBUS MHL Map */
 #define ADV748X_I2C_CEC0x41/* CEC Map */
 #define ADV748X_I2C_SDP0x79/* SDP Map */
 #define ADV748X_I2C_TXB0x48/* CSI-TXB Map */
@@ -48,6 +49,7 @@ enum adv748x_page {
ADV748X_PAGE_EDID,
ADV748X_PAGE_REPEATER,
ADV748X_PAGE_INFOFRAME,
+   ADV748X_PAGE_CBUS,
ADV748X_PAGE_CEC,
ADV748X_PAGE_SDP,
ADV748X_PAGE_TXB,
-- 
2.7.4



[PATCH 0/2] media: i2c: adv748x: Fix CBUS page issue

2018-02-07 Thread Kieran Bingham
From: Kieran Bingham 

The ADV748x has 12 pages mapped on to I2C addresses.

The existing implementation only has 11 of these in the map enumeration, and
this can cause an off-by-one error when programming the map addresses.

This short series simplifies the regmap configuration tables, and adds the
missing CBUS page to better model the device, and remove the off by one error.


Kieran Bingham (2):
  media: i2c: adv748x: Simplify regmap configuration
  media: i2c: adv748x: Add missing CBUS page.

 drivers/media/i2c/adv748x/adv748x-core.c | 114 +++
 drivers/media/i2c/adv748x/adv748x.h  |   2 +
 2 files changed, 27 insertions(+), 89 deletions(-)

-- 
2.7.4



[PATCH] vimc: use correct subdev functions

2018-02-07 Thread Hans Verkuil
Instead of calling everything a MEDIA_ENT_F_ATV_DECODER, pick the
correct functions for these blocks.

Signed-off-by: Hans Verkuil 
---
diff --git a/drivers/media/platform/vimc/vimc-debayer.c 
b/drivers/media/platform/vimc/vimc-debayer.c
index 4d663e89d33f..6e10b63ba9ec 100644
--- a/drivers/media/platform/vimc/vimc-debayer.c
+++ b/drivers/media/platform/vimc/vimc-debayer.c
@@ -533,7 +533,7 @@ static int vimc_deb_comp_bind(struct device *comp, struct 
device *master,
/* Initialize ved and sd */
ret = vimc_ent_sd_register(&vdeb->ved, &vdeb->sd, v4l2_dev,
   pdata->entity_name,
-  MEDIA_ENT_F_ATV_DECODER, 2,
+  MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV, 2,
   (const unsigned long[2]) {MEDIA_PAD_FL_SINK,
   MEDIA_PAD_FL_SOURCE},
   &vimc_deb_ops);
diff --git a/drivers/media/platform/vimc/vimc-scaler.c 
b/drivers/media/platform/vimc/vimc-scaler.c
index e1602e0bc230..e583ec7a91da 100644
--- a/drivers/media/platform/vimc/vimc-scaler.c
+++ b/drivers/media/platform/vimc/vimc-scaler.c
@@ -395,7 +395,7 @@ static int vimc_sca_comp_bind(struct device *comp, struct 
device *master,
/* Initialize ved and sd */
ret = vimc_ent_sd_register(&vsca->ved, &vsca->sd, v4l2_dev,
   pdata->entity_name,
-  MEDIA_ENT_F_ATV_DECODER, 2,
+  MEDIA_ENT_F_PROC_VIDEO_SCALER, 2,
   (const unsigned long[2]) {MEDIA_PAD_FL_SINK,
   MEDIA_PAD_FL_SOURCE},
   &vimc_sca_ops);
diff --git a/drivers/media/platform/vimc/vimc-sensor.c 
b/drivers/media/platform/vimc/vimc-sensor.c
index 457e211514c6..7d9fa9ccdb0e 100644
--- a/drivers/media/platform/vimc/vimc-sensor.c
+++ b/drivers/media/platform/vimc/vimc-sensor.c
@@ -378,7 +378,7 @@ static int vimc_sen_comp_bind(struct device *comp, struct 
device *master,
/* Initialize ved and sd */
ret = vimc_ent_sd_register(&vsen->ved, &vsen->sd, v4l2_dev,
   pdata->entity_name,
-  MEDIA_ENT_F_ATV_DECODER, 1,
+  MEDIA_ENT_F_CAM_SENSOR, 1,
   (const unsigned long[1]) 
{MEDIA_PAD_FL_SOURCE},
   &vimc_sen_ops);
if (ret)


Re: [PATCH v5 03/16] media: rkisp1: Add user space ABI definitions

2018-02-07 Thread Hans Verkuil
On 12/29/2017 08:52 AM, Shunqian Zheng wrote:
> From: Jeffy Chen 
> 
> Add the header for userspace
> 
> Signed-off-by: Jeffy Chen 
> Signed-off-by: Jacob Chen 
> ---
>  include/uapi/linux/rkisp1-config.h | 757 
> +
>  1 file changed, 757 insertions(+)
>  create mode 100644 include/uapi/linux/rkisp1-config.h
> 
> diff --git a/include/uapi/linux/rkisp1-config.h 
> b/include/uapi/linux/rkisp1-config.h
> new file mode 100644
> index 000..0f9f4226
> --- /dev/null
> +++ b/include/uapi/linux/rkisp1-config.h
> @@ -0,0 +1,757 @@



> +/**
> + * enum cifisp_exp_ctrl_auotostop - stop modes

auotostop -> autostop

> + * @CIFISP_EXP_CTRL_AUTOSTOP_0: continous measurement

continous -> continuous

> + * @CIFISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
> + */
> +enum cifisp_exp_ctrl_auotostop {

auotostop -> autostop

> + CIFISP_EXP_CTRL_AUTOSTOP_0 = 0,
> + CIFISP_EXP_CTRL_AUTOSTOP_1 = 1,
> +};

Just noticed this :-)

Regards,

Hans


Re: [PATCH 1/2] media: adv7604: Add support for i2c_new_secondary_device

2018-02-07 Thread Kieran Bingham
Hi Rob,

On 29/01/18 20:08, Rob Herring wrote:
> On Mon, Jan 22, 2018 at 12:49:56PM +, Kieran Bingham wrote:
>> From: Jean-Michel Hautbois 
>>
>> The ADV7604 has thirteen 256-byte maps that can be accessed via the main
>> I²C ports. Each map has it own I²C address and acts as a standard slave
>> device on the I²C bus.
>>
>> Allow a device tree node to override the default addresses so that
>> address conflicts with other devices on the same bus may be resolved at
>> the board description level.
>>
>> Signed-off-by: Jean-Michel Hautbois 
>> [Kieran: Re-adapted for mainline]
>> Signed-off-by: Kieran Bingham 
>> ---
>> Based upon the original posting :
>>   https://lkml.org/lkml/2014/10/22/469
>> ---
>>  .../devicetree/bindings/media/i2c/adv7604.txt  | 18 ++-
> 
> Reviewed-by: Rob Herring 

Thank you.

> In the future, please split bindings to separate patch.

Yes, of course - sorry - I should probably have known better here.

I was clearly being lazy as the original patch had bindings in with the driver.
Although I don't think I've got an excuse for the second patch in the series :D

I've split them out for the v2.

--
Kieran

>>  drivers/media/i2c/adv7604.c| 60 
>> ++
>>  2 files changed, 55 insertions(+), 23 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" 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] drm: adv7511: Add support for i2c_new_secondary_device

2018-02-07 Thread Kieran Bingham
Hi Laurent,

On 29/01/18 10:26, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.

Thanks for your review,

> On Monday, 22 January 2018 14:50:00 EET Kieran Bingham wrote:
>> The ADV7511 has four 256-byte maps that can be accessed via the main I²C
>> ports. Each map has it own I²C address and acts as a standard slave
>> device on the I²C bus.
>>
>> Allow a device tree node to override the default addresses so that
>> address conflicts with other devices on the same bus may be resolved at
>> the board description level.
>>
>> Signed-off-by: Kieran Bingham 
>> ---
>>  .../bindings/display/bridge/adi,adv7511.txt| 10 +-
> 
> I don't mind personally, but device tree maintainers usually ask for DT 
> bindings changes to be split to a separate patch.
> 
>>  drivers/gpu/drm/bridge/adv7511/adv7511.h   |  4 +++
>>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c   | 36 ---
>>  3 files changed, 37 insertions(+), 13 deletions(-)
>>
>> diff --git
>> a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
>> b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
>> index 0047b1394c70..f6bb9f6d3f48 100644
>> --- a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
>> +++ b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
>> @@ -70,6 +70,9 @@ Optional properties:
>>rather than generate its own timings for HDMI output.
>>  - clocks: from common clock binding: reference to the CEC clock.
>>  - clock-names: from common clock binding: must be "cec".
>> +- reg-names : Names of maps with programmable addresses.
>> +It can contain any map needing a non-default address.
>> +Possible maps names are : "main", "edid", "cec", "packet"
> 
> Is the reg-names property (and the additional maps) mandatory or optional ? > 
> If mandatory you should also update the existing DT sources that use those
> bindings.

They are currently optional. I do prefer it that way - but perhaps due to an
issue mentioned below we might need to make this driver mandatory ?


> If optional you should define which I2C addresses will be used when 
> the maps are not specified > (and in that case I think we should go for the
> addresses listed as default in the datasheet, which correspond to the current 
> driver implementation when the main address is 0x3d/0x7a).

The current addresses do not correspond to the datasheet, even when the
implementation main address is set to 0x3d.

Thus, in my opinion - they are currently 'wrong' - but perhaps changing them is
considered breakage too.

A particular issue will arise here too - as on this device - when the device is
in low-power mode (after probe, before use) - the maps will respond on their
*hardware default* addresses (the ones implemented in this patch), and thus
consume that address on the I2C bus regardless of their settings in the driver.


> You should also update the definition of the reg property that currently just 
> states
> 
> - reg: I2C slave address
> 
> And finally you might want to define the term "map" in this context. Here's a 
> proposal (if we make all maps mandatory).
> 
> The ADV7511 internal registers are split into four pages exposed through 
> different I2C addresses, creating four register maps. The I2C addresses of 
> all 
> four maps shall be specified by the reg and reg-names property.
> 
> - reg: I2C slave addresses, one per reg-names entry
> - reg-names: map names, shall be "main", "edid", "cec", "packet"
> 
>>  Required nodes:
>>  
>> @@ -88,7 +91,12 @@ Example
>>  
>>  adv7511w: hdmi@39 {
>>  compatible = "adi,adv7511w";
>> -reg = <39>;
>> +/*
>> + * The EDID page will be accessible on address 0x66 on the i2c
>> + * bus. All other maps continue to use their default addresses.
>> + */
>> +reg = <0x39 0x66>;
>> +reg-names = "main", "edid";
>>  interrupt-parent = <&gpio3>;
>>  interrupts = <29 IRQ_TYPE_EDGE_FALLING>;
>>  clocks = <&cec_clock>;
>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> b/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> index d034b2cb5eee..7d81ce3808e0 100644
>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> @@ -53,8 +53,10 @@
>>  #define ADV7511_REG_POWER   0x41
>>  #define ADV7511_REG_STATUS  0x42
>>  #define ADV7511_REG_EDID_I2C_ADDR   0x43
>> +#define ADV7511_REG_EDID_I2C_ADDR_DEFAULT   0x3f
>>  #define ADV7511_REG_PACKET_ENABLE1  0x44
>>  #define ADV7511_REG_PACKET_I2C_ADDR 0x45
>> +#define ADV7511_REG_PACKET_I2C_ADDR_DEFAULT 0x38
>>  #define ADV7511_REG_DSD_ENABLE  0x46
>>  #define ADV7511_REG_VIDEO_INPUT_CFG20x48
>>  #define ADV7511_REG_INFOFRAME_UPDATE0x4a
>> @@ -89,6 +91,7 @@
>>  #define ADV7511_REG_TMDS_CLOCK_INV  0xde
>>  #define AD

[PATCH 6/7] i2c: add SPDX license info

2018-02-07 Thread Hans Verkuil
From: Hans Verkuil 

Replace the old license information with the corresponding SPDX
license for those drivers Cisco authored.

Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/ad9389b.c   | 14 +-
 drivers/media/i2c/adv7511.c   | 14 +-
 drivers/media/i2c/adv7604.c   | 14 +-
 drivers/media/i2c/adv7842.c   | 15 +--
 drivers/media/i2c/tc358743.c  | 15 +--
 drivers/media/i2c/tc358743_regs.h | 15 +--
 6 files changed, 6 insertions(+), 81 deletions(-)

diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index a056d6cd..91ff06088572 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Analog Devices AD9389B/AD9889B video encoder driver
  *
  * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 /*
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 2817bafc67bf..d23505a411ee 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Analog Devices ADV7511 HDMI Transmitter Device Driver
  *
  * Copyright 2013 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 1544920ec52d..b2caaff945ab 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1,21 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * adv7604 - Analog Devices ADV7604 video decoder driver
  *
  * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
  *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
  */
 
 /*
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 136aa80a834b..fddac32e5051 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * adv7842 - Analog Devices ADV7842 video decoder driver
  *
  * Copyright 2013 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
  */
 
 /*
diff --git a/drivers/medi

[PATCH 3/7] vivid: add SPDX license info

2018-02-07 Thread Hans Verkuil
From: Hans Verkuil 

Replace the old license information with the corresponding SPDX
license.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-cec.c  | 14 +-
 drivers/media/platform/vivid/vivid-cec.h  | 14 +-
 drivers/media/platform/vivid/vivid-core.c | 14 +-
 drivers/media/platform/vivid/vivid-core.h | 14 +-
 drivers/media/platform/vivid/vivid-ctrls.c| 14 +-
 drivers/media/platform/vivid/vivid-ctrls.h| 14 +-
 drivers/media/platform/vivid/vivid-kthread-cap.c  | 14 +-
 drivers/media/platform/vivid/vivid-kthread-cap.h  | 14 +-
 drivers/media/platform/vivid/vivid-kthread-out.c  | 14 +-
 drivers/media/platform/vivid/vivid-kthread-out.h  | 14 +-
 drivers/media/platform/vivid/vivid-osd.c  | 14 +-
 drivers/media/platform/vivid/vivid-osd.h  | 14 +-
 drivers/media/platform/vivid/vivid-radio-common.c | 14 +-
 drivers/media/platform/vivid/vivid-radio-common.h | 14 +-
 drivers/media/platform/vivid/vivid-radio-rx.c | 14 +-
 drivers/media/platform/vivid/vivid-radio-rx.h | 14 +-
 drivers/media/platform/vivid/vivid-radio-tx.c | 14 +-
 drivers/media/platform/vivid/vivid-radio-tx.h | 14 +-
 drivers/media/platform/vivid/vivid-rds-gen.c  | 14 +-
 drivers/media/platform/vivid/vivid-rds-gen.h  | 14 +-
 drivers/media/platform/vivid/vivid-sdr-cap.c  | 14 +-
 drivers/media/platform/vivid/vivid-sdr-cap.h  | 14 +-
 drivers/media/platform/vivid/vivid-vbi-cap.c  | 14 +-
 drivers/media/platform/vivid/vivid-vbi-cap.h  | 14 +-
 drivers/media/platform/vivid/vivid-vbi-gen.c  | 14 +-
 drivers/media/platform/vivid/vivid-vbi-gen.h  | 14 +-
 drivers/media/platform/vivid/vivid-vbi-out.c  | 14 +-
 drivers/media/platform/vivid/vivid-vbi-out.h  | 14 +-
 drivers/media/platform/vivid/vivid-vid-cap.c  | 14 +-
 drivers/media/platform/vivid/vivid-vid-cap.h  | 14 +-
 drivers/media/platform/vivid/vivid-vid-common.c   | 14 +-
 drivers/media/platform/vivid/vivid-vid-common.h   | 14 +-
 drivers/media/platform/vivid/vivid-vid-out.c  | 14 +-
 drivers/media/platform/vivid/vivid-vid-out.h  | 14 +-
 34 files changed, 34 insertions(+), 442 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-cec.c 
b/drivers/media/platform/vivid/vivid-cec.c
index b55d278d38a7..619bd8435b7f 100644
--- a/drivers/media/platform/vivid/vivid-cec.c
+++ b/drivers/media/platform/vivid/vivid-cec.c
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * vivid-cec.c - A Virtual Video Test Driver, cec emulation
  *
  * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #include 
diff --git a/drivers/media/platform/vivid/vivid-cec.h 
b/drivers/media/platform/vivid/vivid-cec.h
index 3926b1422777..7524ed48a914 100644
--- a/drivers/media/platform/vivid/vivid-cec.h
+++ b/drivers/media/platform/vivid/vivid-cec.h
@@ -1,20 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * vivid-cec.h - A Virtual Video Test Driver, cec emulation
  *
  * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #ifdef CONFIG_VIDEO_VIVID_CEC
diff --git a/drivers/media/platform/vivid

[PATCH 0/7] Add SPDX headers for Cisco-authored sources

2018-02-07 Thread Hans Verkuil
From: Hans Verkuil 

This replaces all the old boilerplate license code with the new SPDX
tags for Cisco-authored files in the media subsystem.

Regards,

Hans

Hans Verkuil (7):
  media: v4l2-compat-ioctl32.c: make ctrl_is_pointer work for subdevs
  include/(uapi/)media: add SPDX license info
  vivid: add SPDX license info
  cobalt: add SPDX license info
  cec: add SPDX license info
  i2c: add SPDX license info
  media: add SPDX license info

 drivers/media/cec/cec-adap.c   | 14 +--
 drivers/media/cec/cec-api.c| 14 +--
 drivers/media/cec/cec-core.c   | 14 +--
 drivers/media/cec/cec-edid.c   | 14 +--
 drivers/media/cec/cec-notifier.c   | 14 +--
 drivers/media/cec/cec-pin-priv.h   | 14 +--
 drivers/media/cec/cec-pin.c| 14 +--
 drivers/media/cec/cec-priv.h   | 14 +--
 drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c| 14 +--
 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c  | 14 +--
 drivers/media/i2c/ad9389b.c| 14 +--
 drivers/media/i2c/adv7511.c| 14 +--
 drivers/media/i2c/adv7604.c| 14 +--
 drivers/media/i2c/adv7842.c| 15 +--
 drivers/media/i2c/tc358743.c   | 15 +--
 drivers/media/i2c/tc358743_regs.h  | 15 +--
 drivers/media/pci/cobalt/Makefile  |  1 +
 drivers/media/pci/cobalt/cobalt-alsa-main.c| 14 +--
 drivers/media/pci/cobalt/cobalt-alsa-pcm.c | 14 +--
 drivers/media/pci/cobalt/cobalt-alsa-pcm.h | 14 +--
 drivers/media/pci/cobalt/cobalt-alsa.h | 14 +--
 drivers/media/pci/cobalt/cobalt-cpld.c | 14 +--
 drivers/media/pci/cobalt/cobalt-cpld.h | 14 +--
 drivers/media/pci/cobalt/cobalt-driver.c   | 14 +--
 drivers/media/pci/cobalt/cobalt-driver.h   | 14 +--
 drivers/media/pci/cobalt/cobalt-flash.c| 14 +--
 drivers/media/pci/cobalt/cobalt-flash.h| 14 +--
 drivers/media/pci/cobalt/cobalt-i2c.c  | 14 +--
 drivers/media/pci/cobalt/cobalt-i2c.h  | 14 +--
 drivers/media/pci/cobalt/cobalt-irq.c  | 14 +--
 drivers/media/pci/cobalt/cobalt-irq.h  | 14 +--
 drivers/media/pci/cobalt/cobalt-omnitek.c  | 14 +--
 drivers/media/pci/cobalt/cobalt-omnitek.h  | 14 +--
 drivers/media/pci/cobalt/cobalt-v4l2.c | 14 +--
 drivers/media/pci/cobalt/cobalt-v4l2.h | 14 +--
 .../cobalt/m00233_video_measure_memmap_package.h   | 14 +--
 .../pci/cobalt/m00235_fdma_packer_memmap_package.h | 14 +--
 .../media/pci/cobalt/m00389_cvi_memmap_package.h   | 14 +--
 .../media/pci/cobalt/m00460_evcnt_memmap_package.h | 14 +--
 .../pci/cobalt/m00473_freewheel_memmap_package.h   | 14 +--
 .../m00479_clk_loss_detector_memmap_package.h  | 14 +--
 .../m00514_syncgen_flow_evcnt_memmap_package.h | 14 +--
 drivers/media/platform/cec-gpio/cec-gpio.c | 14 +--
 drivers/media/platform/vivid/vivid-cec.c   | 14 +--
 drivers/media/platform/vivid/vivid-cec.h   | 14 +--
 drivers/media/platform/vivid/vivid-core.c  | 14 +--
 drivers/media/platform/vivid/vivid-core.h  | 14 +--
 drivers/media/platform/vivid/vivid-ctrls.c | 14 +--
 drivers/media/platform/vivid/vivid-ctrls.h | 14 +--
 drivers/media/platform/vivid/vivid-kthread-cap.c   | 14 +--
 drivers/media/platform/vivid/vivid-kthread-cap.h   | 14 +--
 drivers/media/platform/vivid/vivid-kthread-out.c   | 14 +--
 drivers/media/platform/vivid/vivid-kthread-out.h   | 14 +--
 drivers/media/platform/vivid/vivid-osd.c   | 14 +--
 drivers/media/platform/vivid/vivid-osd.h   | 14 +--
 drivers/media/platform/vivid/vivid-radio-common.c  | 14 +--
 drivers/media/platform/vivid/vivid-radio-common.h  | 14 +--
 drivers/media/platform/vivid/vivid-radio-rx.c  | 14 +--
 drivers/media/platform/vivid/vivid-radio-rx.h  | 14 +--
 drivers/media/platform/vivid/vivid-radio-tx.c  | 14 +--
 drivers/media/platform/vivid/vivid-radio-tx.h  | 14 +--
 drivers/media/platform/vivid/vivid-rds-gen.c   | 14 +--
 drivers/media/platform/vivid/vivid-rds-gen.h   | 14 +--
 drivers/media/platform/vivid/vivid-sdr-cap.c   | 14 +--
 drivers/media/platform/vivid/vivid-sdr-cap.h   | 14 +--
 drivers/media/platform/vivid/vivid-vbi-cap.c   | 14 +--

[PATCH 5/7] cec: add SPDX license info

2018-02-07 Thread Hans Verkuil
From: Hans Verkuil 

Replace the old license information with the corresponding SPDX
license.

Signed-off-by: Hans Verkuil 
---
 drivers/media/cec/cec-adap.c | 14 +-
 drivers/media/cec/cec-api.c  | 14 +-
 drivers/media/cec/cec-core.c | 14 +-
 drivers/media/cec/cec-edid.c | 14 +-
 drivers/media/cec/cec-notifier.c | 14 +-
 drivers/media/cec/cec-pin-priv.h | 14 +-
 drivers/media/cec/cec-pin.c  | 14 +-
 drivers/media/cec/cec-priv.h | 14 +-
 8 files changed, 8 insertions(+), 104 deletions(-)

diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c
index 2b1e540587d6..768f7d70b55c 100644
--- a/drivers/media/cec/cec-adap.c
+++ b/drivers/media/cec/cec-adap.c
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * cec-adap.c - HDMI Consumer Electronics Control framework - CEC adapter
  *
  * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #include 
diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c
index 37e468074dc1..af1b562ad2ea 100644
--- a/drivers/media/cec/cec-api.c
+++ b/drivers/media/cec/cec-api.c
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * cec-api.c - HDMI Consumer Electronics Control framework - API
  *
  * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #include 
diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
index a9f9525db9ae..e47ea22b3c23 100644
--- a/drivers/media/cec/cec-core.c
+++ b/drivers/media/cec/cec-core.c
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * cec-core.c - HDMI Consumer Electronics Control framework - Core
  *
  * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #include 
diff --git a/drivers/media/cec/cec-edid.c b/drivers/media/cec/cec-edid.c
index 38e3fec6152b..ec72ac1c0b91 100644
--- a/drivers/media/cec/cec-edid.c
+++ b/drivers/media/cec/cec-edid.c
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * cec-edid - HDMI Consumer Electronics Control EDID & CEC helper functions
  *
  * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWI

[PATCH 4/7] cobalt: add SPDX license info

2018-02-07 Thread Hans Verkuil
From: Hans Verkuil 

Replace the old license information with the corresponding SPDX
license.

Signed-off-by: Hans Verkuil 
---
 drivers/media/pci/cobalt/Makefile  |  1 +
 drivers/media/pci/cobalt/cobalt-alsa-main.c| 14 +-
 drivers/media/pci/cobalt/cobalt-alsa-pcm.c | 14 +-
 drivers/media/pci/cobalt/cobalt-alsa-pcm.h | 14 +-
 drivers/media/pci/cobalt/cobalt-alsa.h | 14 +-
 drivers/media/pci/cobalt/cobalt-cpld.c | 14 +-
 drivers/media/pci/cobalt/cobalt-cpld.h | 14 +-
 drivers/media/pci/cobalt/cobalt-driver.c   | 14 +-
 drivers/media/pci/cobalt/cobalt-driver.h   | 14 +-
 drivers/media/pci/cobalt/cobalt-flash.c| 14 +-
 drivers/media/pci/cobalt/cobalt-flash.h| 14 +-
 drivers/media/pci/cobalt/cobalt-i2c.c  | 14 +-
 drivers/media/pci/cobalt/cobalt-i2c.h  | 14 +-
 drivers/media/pci/cobalt/cobalt-irq.c  | 14 +-
 drivers/media/pci/cobalt/cobalt-irq.h  | 14 +-
 drivers/media/pci/cobalt/cobalt-omnitek.c  | 14 +-
 drivers/media/pci/cobalt/cobalt-omnitek.h  | 14 +-
 drivers/media/pci/cobalt/cobalt-v4l2.c | 14 +-
 drivers/media/pci/cobalt/cobalt-v4l2.h | 14 +-
 .../media/pci/cobalt/m00233_video_measure_memmap_package.h | 14 +-
 .../media/pci/cobalt/m00235_fdma_packer_memmap_package.h   | 14 +-
 drivers/media/pci/cobalt/m00389_cvi_memmap_package.h   | 14 +-
 drivers/media/pci/cobalt/m00460_evcnt_memmap_package.h | 14 +-
 drivers/media/pci/cobalt/m00473_freewheel_memmap_package.h | 14 +-
 .../pci/cobalt/m00479_clk_loss_detector_memmap_package.h   | 14 +-
 .../pci/cobalt/m00514_syncgen_flow_evcnt_memmap_package.h  | 14 +-
 26 files changed, 26 insertions(+), 325 deletions(-)

diff --git a/drivers/media/pci/cobalt/Makefile 
b/drivers/media/pci/cobalt/Makefile
index b328955abbd2..29eddff2f35f 100644
--- a/drivers/media/pci/cobalt/Makefile
+++ b/drivers/media/pci/cobalt/Makefile
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
 cobalt-objs:= cobalt-driver.o cobalt-irq.o cobalt-v4l2.o \
  cobalt-i2c.o cobalt-omnitek.o cobalt-flash.o cobalt-cpld.o \
  cobalt-alsa-main.o cobalt-alsa-pcm.o
diff --git a/drivers/media/pci/cobalt/cobalt-alsa-main.c 
b/drivers/media/pci/cobalt/cobalt-alsa-main.c
index 720e3ad93a9e..e5022b620856 100644
--- a/drivers/media/pci/cobalt/cobalt-alsa-main.c
+++ b/drivers/media/pci/cobalt/cobalt-alsa-main.c
@@ -1,21 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  *  ALSA interface to cobalt PCM capture streams
  *
  *  Copyright 2014-2015 Cisco Systems, Inc. and/or its affiliates.
  *  All rights reserved.
- *
- *  This program is free software; you may redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
- *
- *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- *  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- *  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- *  SOFTWARE.
  */
 
 #include 
diff --git a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c 
b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
index b69b258d39b9..f6a7df13cd04 100644
--- a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
+++ b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
@@ -1,22 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  *  ALSA PCM device for the
  *  ALSA interface to cobalt PCM capture streams
  *
  *  Copyright 2014-2015 Cisco Systems, Inc. and/or its affiliates.
  *  All rights reserved.
- *
- *  This program is free software; you may redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
- *
- *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- *  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- *  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT

[PATCH 2/7] include/(uapi/)media: add SPDX license info

2018-02-07 Thread Hans Verkuil
From: Hans Verkuil 

Replace the old license information with the corresponding SPDX
license for those headers that I authored.

Signed-off-by: Hans Verkuil 
---
 include/media/cec-notifier.h| 14 +-
 include/media/cec-pin.h | 14 +-
 include/media/cec.h | 14 +-
 include/media/i2c/ad9389b.h | 14 +-
 include/media/i2c/adv7511.h | 14 +-
 include/media/i2c/adv7604.h | 15 +--
 include/media/i2c/adv7842.h | 15 +--
 include/media/i2c/tc358743.h| 18 ++
 include/media/i2c/ths7303.h | 10 +-
 include/media/i2c/uda1342.h | 15 +--
 include/media/tpg/v4l2-tpg.h| 14 +-
 include/media/v4l2-dv-timings.h | 15 +--
 include/media/v4l2-rect.h   | 14 +-
 include/uapi/linux/cec-funcs.h  | 29 -
 include/uapi/linux/cec.h| 29 -
 15 files changed, 14 insertions(+), 230 deletions(-)

diff --git a/include/media/cec-notifier.h b/include/media/cec-notifier.h
index 57ec319a7f44..cf0add70b0e7 100644
--- a/include/media/cec-notifier.h
+++ b/include/media/cec-notifier.h
@@ -1,21 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * cec-notifier.h - notify CEC drivers of physical address changes
  *
  * Copyright 2016 Russell King 
  * Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #ifndef LINUX_CEC_NOTIFIER_H
diff --git a/include/media/cec-pin.h b/include/media/cec-pin.h
index 83b3e17e0a07..ed16c6dde0ba 100644
--- a/include/media/cec-pin.h
+++ b/include/media/cec-pin.h
@@ -1,20 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * cec-pin.h - low-level CEC pin control
  *
  * Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #ifndef LINUX_CEC_PIN_H
diff --git a/include/media/cec.h b/include/media/cec.h
index 7cdf71d7125a..9afba9b558df 100644
--- a/include/media/cec.h
+++ b/include/media/cec.h
@@ -1,20 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * cec - HDMI Consumer Electronics Control support header
  *
  * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #ifndef _MEDIA_CEC_H
diff --git a/include/media/i2c/ad9389b.h b/include/media/i2c/ad9389b.h
index 5ba9af869b8b..30f9ea9a1273 100644
--- a/include/media/i2c/ad9389b.h
+++ b/include/media/i2c/ad9389b.h
@@ -1,20 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Analog Devices AD9389B/AD9889B video encoder driver header
  *
  * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foun

[PATCH 1/7] media: v4l2-compat-ioctl32.c: make ctrl_is_pointer work for subdevs

2018-02-07 Thread Hans Verkuil
From: Hans Verkuil 

If the device is of type VFL_TYPE_SUBDEV then vdev->ioctl_ops
is NULL so the 'if (!ops->vidioc_query_ext_ctrl)' check would crash.
Add a test for !ops to the condition.

All sub-devices that have controls will use the control framework,
so they do not have an equivalent to ops->vidioc_query_ext_ctrl.
Returning false if ops is NULL is the correct thing to do here.

Fixes: b8c601e8af ("v4l2-compat-ioctl32.c: fix ctrl_is_pointer")

Signed-off-by: Hans Verkuil 
Acked-by: Sakari Ailus 
Reported-by: Laurent Pinchart 
Reviewed-by: Laurent Pinchart 
Cc:   # for v4.15 and up
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 
b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index bdb5c226d01c..5198c9eeb348 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -770,7 +770,7 @@ static inline bool ctrl_is_pointer(struct file *file, u32 
id)
return ctrl && ctrl->is_ptr;
}
 
-   if (!ops->vidioc_query_ext_ctrl)
+   if (!ops || !ops->vidioc_query_ext_ctrl)
return false;
 
return !ops->vidioc_query_ext_ctrl(file, fh, &qec) &&
-- 
2.15.1



[PATCH 7/7] media: add SPDX license info

2018-02-07 Thread Hans Verkuil
From: Hans Verkuil 

Replace the old license information with the corresponding SPDX
license for the remaining media drivers that Cisco authored.

Signed-off-by: Hans Verkuil 
---
 drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c | 14 +-
 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c   | 14 +-
 drivers/media/platform/cec-gpio/cec-gpio.c  | 14 +-
 drivers/media/radio/radio-raremono.c| 14 +-
 drivers/media/radio/si4713/radio-usb-si4713.c   | 14 +-
 drivers/media/v4l2-core/v4l2-dv-timings.c   | 15 +--
 6 files changed, 6 insertions(+), 79 deletions(-)

diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c 
b/drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c
index 43180204fab2..3a3dc23c560c 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * v4l2-tpg-colors.c - A table that converts colors to various colorspaces
  *
@@ -20,19 +21,6 @@
  * in order to preserve precision.
  *
  * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #include 
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c 
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index 2b3d4ac4dfd4..d248d1fb9d1d 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * v4l2-tpg-core.c - Test Pattern Generator
  *
@@ -5,19 +6,6 @@
  * vivi.c source for the copyright information of those functions.
  *
  * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #include 
diff --git a/drivers/media/platform/cec-gpio/cec-gpio.c 
b/drivers/media/platform/cec-gpio/cec-gpio.c
index 5debdf08fbe7..f1f28cf5c751 100644
--- a/drivers/media/platform/cec-gpio/cec-gpio.c
+++ b/drivers/media/platform/cec-gpio/cec-gpio.c
@@ -1,18 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #include 
diff --git a/drivers/media/radio/radio-raremono.c 
b/drivers/media/radio/radio-raremono.c
index 70a2c86774ce..9a5079d64c4a 100644
--- a/drivers/media/radio/radio-raremono.c
+++ b/drivers/media/radio/radio-raremono.c
@@ -1,18 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright 2013 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
- *
- * This program is free software; you may redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANT

[PATCH v3 0/2] media: v4l: Add support for the Cadence MIPI-CSI2 TX controller

2018-02-07 Thread Maxime Ripard
Hi,

Here is an attempt at supporting the MIPI-CSI2 TX block from Cadence.

This IP block is able to receive 4 video streams and stream them over
a MIPI-CSI2 link using up to 4 lanes. Those streams are basically the
interfaces to controllers generating some video signals, like a camera
or a pattern generator.

It is able to map input streams to CSI2 virtual channels and datatypes
dynamically. The streaming devices choose their virtual channels
through an additional signal that is transparent to the CSI2-TX. The
datatypes however are yet another additional input signal, and can be
mapped to any CSI2 datatypes.

Since v4l2 doesn't really allow for that setup at the moment, this
preliminary version is a rather dumb one in order to start the
discussion on how to address this properly.

Let me know what you think!
Maxime

Changes from v2:
  - Use SPDX license header
  - Use the lane mapping from DT

Changes from v1:
  - Add a subdev notifier and start our downstream subdevice in
s_stream  
  - Based the decision to enable the stream or not on the link state
instead of whether a format was being set on the pad
  - Put the controller back in reset when stopping the pipeline
  - Clarified the enpoints number in the DT binding
  - Added a default format for the pads
  - Added some missing const
  - Added more explicit comments
  - Rebased on 4.15

Maxime Ripard (2):
  dt-bindings: media: Add Cadence MIPI-CSI2 TX Device Tree bindings
  v4l: cadence: Add Cadence MIPI-CSI2 TX driver

 .../devicetree/bindings/media/cdns,csi2tx.txt  |  98 
 drivers/media/platform/cadence/Kconfig |   6 +
 drivers/media/platform/cadence/Makefile|   1 +
 drivers/media/platform/cadence/cdns-csi2tx.c   | 582 +
 4 files changed, 687 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2tx.txt
 create mode 100644 drivers/media/platform/cadence/cdns-csi2tx.c

-- 
2.14.3



[PATCH v3 2/2] v4l: cadence: Add Cadence MIPI-CSI2 TX driver

2018-02-07 Thread Maxime Ripard
The Cadence MIPI-CSI2 TX controller is an hardware block meant to be used
as a bridge between pixel interfaces and a CSI-2 bus.

It supports operating with an internal or external D-PHY, with up to 4
lanes, or without any D-PHY. The current code only supports the former
case.

While the virtual channel input on the pixel interface can be directly
mapped to CSI2, the datatype input is actually a selection signal (3-bits)
mapping to a table of up to 8 preconfigured datatypes/formats (programmed
at start-up)

The block supports up to 8 input datatypes.

Signed-off-by: Maxime Ripard 
---
 drivers/media/platform/cadence/Kconfig   |   6 +
 drivers/media/platform/cadence/Makefile  |   1 +
 drivers/media/platform/cadence/cdns-csi2tx.c | 582 +++
 3 files changed, 589 insertions(+)
 create mode 100644 drivers/media/platform/cadence/cdns-csi2tx.c

diff --git a/drivers/media/platform/cadence/Kconfig 
b/drivers/media/platform/cadence/Kconfig
index d1b6bbb6a0eb..db49328ee8b2 100644
--- a/drivers/media/platform/cadence/Kconfig
+++ b/drivers/media/platform/cadence/Kconfig
@@ -9,4 +9,10 @@ config VIDEO_CADENCE_CSI2RX
depends on VIDEO_V4L2_SUBDEV_API
select V4L2_FWNODE
 
+config VIDEO_CADENCE_CSI2TX
+   tristate "Cadence MIPI-CSI2 TX Controller"
+   depends on MEDIA_CONTROLLER
+   depends on VIDEO_V4L2_SUBDEV_API
+   select V4L2_FWNODE
+
 endif
diff --git a/drivers/media/platform/cadence/Makefile 
b/drivers/media/platform/cadence/Makefile
index 99a4086b7448..7fe992273162 100644
--- a/drivers/media/platform/cadence/Makefile
+++ b/drivers/media/platform/cadence/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_VIDEO_CADENCE_CSI2RX) += cdns-csi2rx.o
+obj-$(CONFIG_VIDEO_CADENCE_CSI2TX) += cdns-csi2tx.o
diff --git a/drivers/media/platform/cadence/cdns-csi2tx.c 
b/drivers/media/platform/cadence/cdns-csi2tx.c
new file mode 100644
index ..3cc58c26d226
--- /dev/null
+++ b/drivers/media/platform/cadence/cdns-csi2tx.c
@@ -0,0 +1,582 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Driver for Cadence MIPI-CSI2 TX Controller
+ *
+ * Copyright (C) 2017 Cadence Design Systems Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define CSI2TX_DEVICE_CONFIG_REG   0x00
+
+#define CSI2TX_CONFIG_REG  0x20
+#define CSI2TX_CONFIG_CFG_REQ  BIT(2)
+#define CSI2TX_CONFIG_SRST_REQ BIT(1)
+
+#define CSI2TX_DPHY_CFG_REG0x28
+#define CSI2TX_DPHY_CFG_CLK_RESET  BIT(16)
+#define CSI2TX_DPHY_CFG_LANE_RESET(n)  BIT((n) + 12)
+#define CSI2TX_DPHY_CFG_MODE_MASK  GENMASK(9, 8)
+#define CSI2TX_DPHY_CFG_MODE_LPDT  (2 << 8)
+#define CSI2TX_DPHY_CFG_MODE_HS(1 << 8)
+#define CSI2TX_DPHY_CFG_MODE_ULPS  (0 << 8)
+#define CSI2TX_DPHY_CFG_CLK_ENABLE BIT(4)
+#define CSI2TX_DPHY_CFG_LANE_ENABLE(n) BIT(n)
+
+#define CSI2TX_DPHY_CLK_WAKEUP_REG 0x2c
+#define CSI2TX_DPHY_CLK_WAKEUP_ULPS_CYCLES(n)  ((n) & 0x)
+
+#define CSI2TX_DT_CFG_REG(n)   (0x80 + (n) * 8)
+#define CSI2TX_DT_CFG_DT(n)(((n) & 0x3f) << 2)
+
+#define CSI2TX_DT_FORMAT_REG(n)(0x84 + (n) * 8)
+#define CSI2TX_DT_FORMAT_BYTES_PER_LINE(n) (((n) & 0x) << 16)
+#define CSI2TX_DT_FORMAT_MAX_LINE_NUM(n)   ((n) & 0x)
+
+#define CSI2TX_STREAM_IF_CFG_REG(n)(0x100 + (n) * 4)
+#define CSI2TX_STREAM_IF_CFG_FILL_LEVEL(n) ((n) & 0x1f)
+
+#define CSI2RX_LANES_MAX   4
+#define CSI2TX_STREAMS_MAX 4
+
+enum csi2tx_pads {
+   CSI2TX_PAD_SOURCE,
+   CSI2TX_PAD_SINK_STREAM0,
+   CSI2TX_PAD_SINK_STREAM1,
+   CSI2TX_PAD_SINK_STREAM2,
+   CSI2TX_PAD_SINK_STREAM3,
+   CSI2TX_PAD_MAX,
+};
+
+struct csi2tx_fmt {
+   u32 mbus;
+   u32 dt;
+   u32 bpp;
+};
+
+struct csi2tx_priv {
+   struct device   *dev;
+   atomic_tcount;
+
+   void __iomem*base;
+
+   struct clk  *esc_clk;
+   struct clk  *p_clk;
+   struct clk  *pixel_clk[CSI2TX_STREAMS_MAX];
+
+   struct v4l2_subdev  subdev;
+   struct v4l2_async_notifier  notifier;
+   struct media_padpads[CSI2TX_PAD_MAX];
+   struct v4l2_mbus_framefmt   pad_fmts[CSI2TX_PAD_MAX];
+
+   boolhas_internal_dphy;
+   u8  lanes[CSI2RX_LANES_MAX];
+   unsigned intnum_lanes;
+   unsigned intmax_lanes;
+   unsigned intmax_streams;
+
+   /* Remote source */
+   struct v4l2_async_subdevasd;
+   struct v4l2_subdev  *sink_subdev;
+   int sink_pad;
+};
+
+static con

[PATCH v3 1/2] dt-bindings: media: Add Cadence MIPI-CSI2 TX Device Tree bindings

2018-02-07 Thread Maxime Ripard
The Cadence MIPI-CSI2 TX controller is a CSI2 bridge that supports up to 4
video streams and can output on up to 4 CSI-2 lanes, depending on the
hardware implementation.

It can operate with an external D-PHY, an internal one or no D-PHY at all
in some configurations.

Acked-by: Rob Herring 
Signed-off-by: Maxime Ripard 
---
 .../devicetree/bindings/media/cdns,csi2tx.txt  | 98 ++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2tx.txt

diff --git a/Documentation/devicetree/bindings/media/cdns,csi2tx.txt 
b/Documentation/devicetree/bindings/media/cdns,csi2tx.txt
new file mode 100644
index ..acbbd625a75f
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/cdns,csi2tx.txt
@@ -0,0 +1,98 @@
+Cadence MIPI-CSI2 TX controller
+===
+
+The Cadence MIPI-CSI2 TX controller is a CSI-2 bridge supporting up to
+4 CSI lanes in output, and up to 4 different pixel streams in input.
+
+Required properties:
+  - compatible: must be set to "cdns,csi2tx"
+  - reg: base address and size of the memory mapped region
+  - clocks: phandles to the clocks driving the controller
+  - clock-names: must contain:
+* esc_clk: escape mode clock
+* p_clk: register bank clock
+* pixel_if[0-3]_clk: pixel stream output clock, one for each stream
+ implemented in hardware, between 0 and 3
+
+Optional properties
+  - phys: phandle to the D-PHY. If it is set, phy-names need to be set
+  - phy-names: must contain dphy
+
+Required subnodes:
+  - ports: A ports node with one port child node per device input and output
+   port, in accordance with the video interface bindings defined in
+   Documentation/devicetree/bindings/media/video-interfaces.txt. The
+   port nodes numbered as follows.
+
+   Port Description
+   -
+   0CSI-2 output
+   1Stream 0 input
+   2Stream 1 input
+   3Stream 2 input
+   4Stream 3 input
+
+   The stream input port nodes are optional if they are not
+   connected to anything at the hardware level or implemented
+   in the design. Since there is only one endpoint per port,
+   the endpoints are not numbered.
+
+Example:
+
+csi2tx: csi-bridge@0d0e1000 {
+   compatible = "cdns,csi2tx";
+   reg = <0x0d0e1000 0x1000>;
+   clocks = <&byteclock>, <&byteclock>,
+<&coreclock>, <&coreclock>,
+<&coreclock>, <&coreclock>;
+   clock-names = "p_clk", "esc_clk",
+ "pixel_if0_clk", "pixel_if1_clk",
+ "pixel_if2_clk", "pixel_if3_clk";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   csi2tx_out: endpoint {
+   remote-endpoint = <&remote_in>;
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   csi2tx_in_stream0: endpoint {
+   remote-endpoint = <&stream0_out>;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   csi2tx_in_stream1: endpoint {
+   remote-endpoint = <&stream1_out>;
+   };
+   };
+
+   port@3 {
+   reg = <3>;
+
+   csi2tx_in_stream2: endpoint {
+   remote-endpoint = <&stream2_out>;
+   };
+   };
+
+   port@4 {
+   reg = <4>;
+
+   csi2tx_in_stream3: endpoint {
+   remote-endpoint = <&stream3_out>;
+   };
+   };
+   };
+};
-- 
2.14.3



[PATCH v6 2/2] v4l: cadence: Add Cadence MIPI-CSI2 RX driver

2018-02-07 Thread Maxime Ripard
The Cadence CSI-2 RX Controller is an hardware block meant to be used as a
bridge between a CSI-2 bus and pixel grabbers.

It supports operating with internal or external D-PHY, with up to 4 lanes,
or without any D-PHY. The current code only supports the former case.

It also support dynamic mapping of the CSI-2 virtual channels to the
associated pixel grabbers, but that isn't allowed at the moment either.

Signed-off-by: Maxime Ripard 
---
 drivers/media/platform/Kconfig   |   1 +
 drivers/media/platform/Makefile  |   2 +
 drivers/media/platform/cadence/Kconfig   |  12 +
 drivers/media/platform/cadence/Makefile  |   1 +
 drivers/media/platform/cadence/cdns-csi2rx.c | 472 +++
 5 files changed, 488 insertions(+)
 create mode 100644 drivers/media/platform/cadence/Kconfig
 create mode 100644 drivers/media/platform/cadence/Makefile
 create mode 100644 drivers/media/platform/cadence/cdns-csi2rx.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index fd0c99859d6f..6e790a317fbc 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -26,6 +26,7 @@ config VIDEO_VIA_CAMERA
 #
 # Platform multimedia device configuration
 #
+source "drivers/media/platform/cadence/Kconfig"
 
 source "drivers/media/platform/davinci/Kconfig"
 
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 003b0bb2cddf..1cd2984c55d1 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -3,6 +3,8 @@
 # Makefile for the video capture/playback device drivers.
 #
 
+obj-$(CONFIG_VIDEO_CADENCE)+= cadence/
+
 obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
 
 obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o
diff --git a/drivers/media/platform/cadence/Kconfig 
b/drivers/media/platform/cadence/Kconfig
new file mode 100644
index ..d1b6bbb6a0eb
--- /dev/null
+++ b/drivers/media/platform/cadence/Kconfig
@@ -0,0 +1,12 @@
+config VIDEO_CADENCE
+   bool "Cadence Video Devices"
+
+if VIDEO_CADENCE
+
+config VIDEO_CADENCE_CSI2RX
+   tristate "Cadence MIPI-CSI2 RX Controller v1.3"
+   depends on MEDIA_CONTROLLER
+   depends on VIDEO_V4L2_SUBDEV_API
+   select V4L2_FWNODE
+
+endif
diff --git a/drivers/media/platform/cadence/Makefile 
b/drivers/media/platform/cadence/Makefile
new file mode 100644
index ..99a4086b7448
--- /dev/null
+++ b/drivers/media/platform/cadence/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_CADENCE_CSI2RX) += cdns-csi2rx.o
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c 
b/drivers/media/platform/cadence/cdns-csi2rx.c
new file mode 100644
index ..c532583cc1a6
--- /dev/null
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -0,0 +1,472 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Driver for Cadence MIPI-CSI2 RX Controller v1.3
+ *
+ * Copyright (C) 2017 Cadence Design Systems Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define CSI2RX_DEVICE_CFG_REG  0x000
+
+#define CSI2RX_SOFT_RESET_REG  0x004
+#define CSI2RX_SOFT_RESET_PROTOCOL BIT(1)
+#define CSI2RX_SOFT_RESET_FRONTBIT(0)
+
+#define CSI2RX_STATIC_CFG_REG  0x008
+#define CSI2RX_STATIC_CFG_DLANE_MAP(llane, plane)  ((plane) << (16 + 
(llane) * 4))
+#define CSI2RX_STATIC_CFG_LANES_MASK   GENMASK(11, 8)
+
+#define CSI2RX_STREAM_BASE(n)  (((n) + 1) * 0x100)
+
+#define CSI2RX_STREAM_CTRL_REG(n)  (CSI2RX_STREAM_BASE(n) + 0x000)
+#define CSI2RX_STREAM_CTRL_START   BIT(0)
+
+#define CSI2RX_STREAM_DATA_CFG_REG(n)  (CSI2RX_STREAM_BASE(n) + 0x008)
+#define CSI2RX_STREAM_DATA_CFG_EN_VC_SELECTBIT(31)
+#define CSI2RX_STREAM_DATA_CFG_VC_SELECT(n)BIT((n) + 16)
+
+#define CSI2RX_STREAM_CFG_REG(n)   (CSI2RX_STREAM_BASE(n) + 0x00c)
+#define CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF  (1 << 8)
+
+#define CSI2RX_LANES_MAX   4
+#define CSI2RX_STREAMS_MAX 4
+
+enum csi2rx_pads {
+   CSI2RX_PAD_SINK,
+   CSI2RX_PAD_SOURCE_STREAM0,
+   CSI2RX_PAD_SOURCE_STREAM1,
+   CSI2RX_PAD_SOURCE_STREAM2,
+   CSI2RX_PAD_SOURCE_STREAM3,
+   CSI2RX_PAD_MAX,
+};
+
+struct csi2rx_priv {
+   struct device   *dev;
+   atomic_tcount;
+
+   void __iomem*base;
+   struct clk  *sys_clk;
+   struct clk  *p_clk;
+   struct clk  *pixel_clk[CSI2RX_STREAMS_MAX];
+   struct phy  *dphy;
+
+   u8  lanes[CSI2RX_LANES_MAX];
+   u8  num_lanes;
+   u8  max_lanes;
+   u8  

[PATCH v6 1/2] dt-bindings: media: Add Cadence MIPI-CSI2 RX Device Tree bindings

2018-02-07 Thread Maxime Ripard
The Cadence MIPI-CSI2 RX controller is a CSI2RX bridge that supports up to
4 CSI-2 lanes, and can route the frames to up to 4 streams, depending on
the hardware implementation.

It can operate with an external D-PHY, an internal one or no D-PHY at all
in some configurations.

Acked-by: Rob Herring 
Acked-by: Benoit Parrot 
Acked-by: Sakari Ailus 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Maxime Ripard 
---
 .../devicetree/bindings/media/cdns,csi2rx.txt  | 100 +
 1 file changed, 100 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt

diff --git a/Documentation/devicetree/bindings/media/cdns,csi2rx.txt 
b/Documentation/devicetree/bindings/media/cdns,csi2rx.txt
new file mode 100644
index ..56d51902b2eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/cdns,csi2rx.txt
@@ -0,0 +1,100 @@
+Cadence MIPI-CSI2 RX controller
+===
+
+The Cadence MIPI-CSI2 RX controller is a CSI-2 bridge supporting up to 4 CSI
+lanes in input, and 4 different pixel streams in output.
+
+Required properties:
+  - compatible: must be set to "cdns,csi2rx" and an SoC-specific compatible
+  - reg: base address and size of the memory mapped region
+  - clocks: phandles to the clocks driving the controller
+  - clock-names: must contain:
+* sys_clk: main clock
+* p_clk: register bank clock
+* pixel_if[0-3]_clk: pixel stream output clock, one for each stream
+ implemented in hardware, between 0 and 3
+
+Optional properties:
+  - phys: phandle to the external D-PHY, phy-names must be provided
+  - phy-names: must contain dphy, if the implementation uses an
+   external D-PHY
+
+Required subnodes:
+  - ports: A ports node with one port child node per device input and output
+   port, in accordance with the video interface bindings defined in
+   Documentation/devicetree/bindings/media/video-interfaces.txt. The
+   port nodes numbered as follows.
+
+   Port Description
+   -
+   0CSI-2 input
+   1Stream 0 output
+   2Stream 1 output
+   3Stream 2 output
+   4Stream 3 output
+
+   The stream output port nodes are optional if they are not
+   connected to anything at the hardware level or implemented
+   in the design.Since there is only one endpoint per port,
+   the endpoints are not numbered.
+
+
+Example:
+
+csi2rx: csi-bridge@0d06 {
+   compatible = "cdns,csi2rx";
+   reg = <0x0d06 0x1000>;
+   clocks = <&byteclock>, <&byteclock>
+<&coreclock>, <&coreclock>,
+<&coreclock>, <&coreclock>;
+   clock-names = "sys_clk", "p_clk",
+ "pixel_if0_clk", "pixel_if1_clk",
+ "pixel_if2_clk", "pixel_if3_clk";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   csi2rx_in_sensor: endpoint {
+   remote-endpoint = <&sensor_out_csi2rx>;
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   csi2rx_out_grabber0: endpoint {
+   remote-endpoint = <&grabber0_in_csi2rx>;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   csi2rx_out_grabber1: endpoint {
+   remote-endpoint = <&grabber1_in_csi2rx>;
+   };
+   };
+
+   port@3 {
+   reg = <3>;
+
+   csi2rx_out_grabber2: endpoint {
+   remote-endpoint = <&grabber2_in_csi2rx>;
+   };
+   };
+
+   port@4 {
+   reg = <4>;
+
+   csi2rx_out_grabber3: endpoint {
+   remote-endpoint = <&grabber3_in_csi2rx>;
+   };
+   };
+   };
+};
-- 
2.14.3



[PATCH v6 0/2] media: v4l: Add support for the Cadence MIPI-CSI2 RX

2018-02-07 Thread Maxime Ripard
Hi,

Here is the sixth attempt at supporting the MIPI-CSI2 RX block from
Cadence.

This IP block is able to receive CSI data over up to 4 lanes, and
split it to over 4 streams. Those streams are basically the interfaces
to the video grabbers that will perform the capture.

It is able to map streams to both CSI datatypes and virtual channels,
dynamically. This is unclear at this point what the right way to
support it would be, so the driver only uses a static mapping between
the virtual channels and streams, and ignores the data types.

Let me know what you think!
Maxime

Changes from v5:
  - Use SPDX license header
  - Fix the lane mapping logic and map unused logical lanes only to unused
physical lanes. Added a comment to explain why.

Changes from v4:
  - Rebased on top of 4.15
  - Fixed a lane mapping issue that prevented the CSI2-RX device to operate
properly.
  - Reworded the output endpoints documentation in the binding

Changes from v3:
  - Removed stale printk
  - Propagate start/stop functions error code to s_stream
  - Renamed the DT bindings files
  - Clarified the output ports wording in the DT binding doc
  - Added a define for the maximum number of lanes
  - Rebased on top of Sakari's serie
  - Gathered tags based on the reviews

Changes from v2:
  - Added reference counting for the controller initialisation
  - Fixed checkpatch warnings
  - Moved the sensor initialisation after the DPHY configuration
  - Renamed the sensor fields to source for consistency
  - Defined some variables
  - Renamed a few structures variables
  - Added internal and external phy errors messages
  - Reworked the binding slighty by making the external D-PHY optional
  - Moved the notifier registration in the probe function
  - Removed some clocks that are not system clocks
  - Added clocks enabling where needed
  - Added the code to remap the data lanes
  - Changed the memory allocator for the non-devm function, and a
comment explaining why
  - Reworked the binding wording

Changes from v1:
  - Amended the DT bindings as suggested by Rob
  - Rebase on top of 4.13-rc1 and latest Niklas' serie iteration

Maxime Ripard (2):
  dt-bindings: media: Add Cadence MIPI-CSI2 RX Device Tree bindings
  v4l: cadence: Add Cadence MIPI-CSI2 RX driver

 .../devicetree/bindings/media/cdns,csi2rx.txt  | 100 +
 drivers/media/platform/Kconfig |   1 +
 drivers/media/platform/Makefile|   2 +
 drivers/media/platform/cadence/Kconfig |  12 +
 drivers/media/platform/cadence/Makefile|   1 +
 drivers/media/platform/cadence/cdns-csi2rx.c   | 472 +
 6 files changed, 588 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/cdns,csi2rx.txt
 create mode 100644 drivers/media/platform/cadence/Kconfig
 create mode 100644 drivers/media/platform/cadence/Makefile
 create mode 100644 drivers/media/platform/cadence/cdns-csi2rx.c

-- 
2.14.3



Re: [PATCH v5] media: imx258: Add imx258 camera sensor driver

2018-02-07 Thread Sakari Ailus
Hi Andy,

Thanks for the update.

On Fri, Jan 26, 2018 at 01:58:55AM +0800, Andy Yeh wrote:
> Add a V4L2 sub-device driver for the Sony IMX258 image sensor.
> This is a camera sensor using the I2C bus for control and the
> CSI-2 bus for data.
> 
> Signed-off-by: Andy Yeh 
> Signed-off-by: Jason Chen 
> Signed-off-by: Alan Chiang 
> ---
> since v2:
> -- Update the streaming function to remove SW_STANDBY in the beginning.
> -- Adjust the delay time from 1ms to 12ms before set stream-on register.
> since v3:
> -- fix the sd.entity to make code be compiled on the mainline kernel.
> since v4:
> -- Enabled AG, DG, and Exposure time control correctly.

This patch seems to include also DIGITAL_GAIN control support but also the
removal of the VBLANK control from s_ctrl callback. Is there still an
intent to support the VBLANK control?

Also registers are written one octet at a time rather than two, which could
lead to sensor using settings that are only half-updated (does the
datasheet say this is safe?). Is there a reason for this?

Seems fine otherwise to me.

-- 
Kind regards,

Sakari Ailus
sakari.ai...@linux.intel.com


Re: [PATCH 4/4] add video control handlers using V4L2 control framework

2018-02-07 Thread Hans Verkuil
On 02/07/18 14:00, Florian Echtler wrote:
> This patch registers four standard control handlers using the corresponding
> V4L2 framework.
> 
> Signed-off-by: Florian Echtler 
> ---
>  drivers/input/touchscreen/sur40.c | 64 
> +++
>  1 file changed, 64 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/sur40.c 
> b/drivers/input/touchscreen/sur40.c
> index d6fa25e..b92325b 100644
> --- a/drivers/input/touchscreen/sur40.c
> +++ b/drivers/input/touchscreen/sur40.c
> @@ -38,6 +38,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -209,6 +210,7 @@ struct sur40_state {
>   struct video_device vdev;
>   struct mutex lock;
>   struct v4l2_pix_format pix_fmt;
> + struct v4l2_ctrl_handler ctrls;

Please rename this to either hdl or ctrl_handler. 'ctrls' is confusing.

>  
>   struct vb2_queue queue;
>   struct list_head buf_list;
> @@ -218,6 +220,7 @@ struct sur40_state {
>   struct sur40_data *bulk_in_buffer;
>   size_t bulk_in_size;
>   u8 bulk_in_epaddr;
> + u8 vsvideo;
>  
>   char phys[64];
>  };
> @@ -231,6 +234,11 @@ struct sur40_buffer {
>  static const struct video_device sur40_video_device;
>  static const struct vb2_queue sur40_queue;
>  static void sur40_process_video(struct sur40_state *sur40);
> +static int sur40_s_ctrl(struct v4l2_ctrl *ctrl);
> +
> +static const struct v4l2_ctrl_ops sur40_ctrl_ops = {
> + .s_ctrl = sur40_s_ctrl,
> +};
>  
>  /*
>   * Note: an earlier, non-public version of this driver used 
> USB_RECIP_ENDPOINT
> @@ -737,6 +745,36 @@ static int sur40_probe(struct usb_interface *interface,
>   sur40->vdev.queue = &sur40->queue;
>   video_set_drvdata(&sur40->vdev, sur40);
>  
> + /* initialize the control handler for 4 controls */
> + v4l2_ctrl_handler_init(&sur40->ctrls, 4);
> + sur40->v4l2.ctrl_handler = &sur40->ctrls;
> + sur40->vsvideo = (SUR40_CONTRAST_DEF << 4) | SUR40_GAIN_DEF;
> +
> + v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_BRIGHTNESS,
> +   SUR40_BRIGHTNESS_MIN, SUR40_BRIGHTNESS_MAX, 1, clamp(brightness,
> +   (uint)SUR40_BRIGHTNESS_MIN, (uint)SUR40_BRIGHTNESS_MAX));
> +
> + v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_CONTRAST,
> +   SUR40_CONTRAST_MIN, SUR40_CONTRAST_MAX, 1, clamp(contrast,
> +   (uint)SUR40_CONTRAST_MIN, (uint)SUR40_CONTRAST_MAX));
> +
> + v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_GAIN,
> +   SUR40_GAIN_MIN, SUR40_GAIN_MAX, 1, clamp(gain,
> +   (uint)SUR40_GAIN_MIN, (uint)SUR40_GAIN_MAX));
> +
> + v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops,
> +   V4L2_CID_BACKLIGHT_COMPENSATION, SUR40_BACKLIGHT_MIN,
> +   SUR40_BACKLIGHT_MAX, 1, SUR40_BACKLIGHT_DEF);
> +
> + v4l2_ctrl_handler_setup(&sur40->ctrls);
> +
> + if (sur40->ctrls.error) {
> + dev_err(&interface->dev,
> + "Unable to register video controls.");
> + v4l2_ctrl_handler_free(&sur40->ctrls);
> + goto err_unreg_v4l2;
> + }
> +
>   error = video_register_device(&sur40->vdev, VFL_TYPE_TOUCH, -1);
>   if (error) {
>   dev_err(&interface->dev,
> @@ -769,6 +807,7 @@ static void sur40_disconnect(struct usb_interface 
> *interface)
>  {
>   struct sur40_state *sur40 = usb_get_intfdata(interface);
>  
> + v4l2_ctrl_handler_free(&sur40->ctrls);
>   video_unregister_device(&sur40->vdev);
>   v4l2_device_unregister(&sur40->v4l2);
>  
> @@ -962,6 +1001,31 @@ static int sur40_vidioc_g_fmt(struct file *file, void 
> *priv,
>   return 0;
>  }
>  
> +static int sur40_s_ctrl(struct v4l2_ctrl *ctrl)
> +{
> + struct sur40_state *sur40  = container_of(ctrl->handler,
> +   struct sur40_state, ctrls);
> + u8 value = sur40->vsvideo;
> +
> + switch (ctrl->id) {
> + case V4L2_CID_BRIGHTNESS:
> + sur40_set_irlevel(sur40, ctrl->val);
> + break;
> + case V4L2_CID_CONTRAST:
> + value = (value & 0x0F) | (ctrl->val << 4);
> + sur40_set_vsvideo(sur40, value);
> + break;
> + case V4L2_CID_GAIN:
> + value = (value & 0xF0) | (ctrl->val);
> + sur40_set_vsvideo(sur40, value);
> + break;
> + case V4L2_CID_BACKLIGHT_COMPENSATION:
> + sur40_set_preprocessor(sur40, ctrl->val);
> + break;
> + }
> + return 0;
> +}
> +
>  static int sur40_ioctl_parm(struct file *file, void *priv,
>   struct v4l2_streamparm *p)
>  {
> 

Looks good otherwise.

Regards,

Hans


Re: [PATCH 2/4] add default settings and module parameters for video controls

2018-02-07 Thread Hans Verkuil
On 02/07/18 14:00, Florian Echtler wrote:
> This patch adds parameter definitions and module parameters for the four
> userspace controls that the SUR40 can currently provide.
> 
> Signed-off-by: Florian Echtler 
> ---
>  drivers/input/touchscreen/sur40.c | 28 
>  1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/sur40.c 
> b/drivers/input/touchscreen/sur40.c
> index 8375b06..8a5b031 100644
> --- a/drivers/input/touchscreen/sur40.c
> +++ b/drivers/input/touchscreen/sur40.c
> @@ -149,6 +149,34 @@ struct sur40_image_header {
>  #define SUR40_TOUCH  0x02
>  #define SUR40_TAG0x04
>  
> +/* video controls */
> +#define SUR40_BRIGHTNESS_MAX 0xFF
> +#define SUR40_BRIGHTNESS_MIN 0x00
> +#define SUR40_BRIGHTNESS_DEF 0xFF
> +
> +#define SUR40_CONTRAST_MAX 0x0F
> +#define SUR40_CONTRAST_MIN 0x00
> +#define SUR40_CONTRAST_DEF 0x0A

It's kernel style to use lowercase hex values.

> +
> +#define SUR40_GAIN_MAX 0x09
> +#define SUR40_GAIN_MIN 0x00
> +#define SUR40_GAIN_DEF 0x08
> +
> +#define SUR40_BACKLIGHT_MAX 0x01
> +#define SUR40_BACKLIGHT_MIN 0x00
> +#define SUR40_BACKLIGHT_DEF 0x01
> +
> +/* module parameters */
> +static uint brightness = SUR40_BRIGHTNESS_DEF;
> +module_param(brightness, uint, 0644);
> +MODULE_PARM_DESC(brightness, "set initial brightness");

No range in the param description? I think you can do some macro magic so you
can use the MIN/MAX defines in the string.

Regards,

Hans

> +static uint contrast = SUR40_CONTRAST_DEF;
> +module_param(contrast, uint, 0644);
> +MODULE_PARM_DESC(contrast, "set initial contrast");
> +static uint gain = SUR40_GAIN_DEF;
> +module_param(gain, uint, 0644);
> +MODULE_PARM_DESC(gain, "set initial gain");
> +
>  static const struct v4l2_pix_format sur40_pix_format[] = {
>   {
>   .pixelformat = V4L2_TCH_FMT_TU08,
> 



[PATCH v3] add video controls for SUR40 driver

2018-02-07 Thread Florian Echtler
As discussed previously, here's the third iteration of my patch to add
control functions for the SUR40 driver, with (hopefully) correct handling
of default values/module parameters, using the V4L2 control framework.

Best regards, Florian



[PATCH 3/4] add panel register access functions

2018-02-07 Thread Florian Echtler
These functions provide write access to the internal LCD panel registers
which also control the sensor. They can be used to disable the
preprocessor, set the illumination brightness, and adjust gain/contrast
(which are stored together in one register internally called "vsvideo").

Signed-off-by: Florian Echtler 
---
 drivers/input/touchscreen/sur40.c | 75 +++
 1 file changed, 75 insertions(+)

diff --git a/drivers/input/touchscreen/sur40.c 
b/drivers/input/touchscreen/sur40.c
index 8a5b031..d6fa25e 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -251,6 +251,81 @@ static int sur40_command(struct sur40_state *dev,
   0x00, index, buffer, size, 1000);
 }
 
+/* poke a byte in the panel register space */
+static int sur40_poke(struct sur40_state *dev, u8 offset, u8 value)
+{
+   int result;
+   u8 index = 0x96; // 0xae for permanent write
+
+   result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+   SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+   0x32, index, NULL, 0, 1000);
+   if (result < 0)
+   goto error;
+   msleep(5);
+
+   result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+   SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+   0x72, offset, NULL, 0, 1000);
+   if (result < 0)
+   goto error;
+   msleep(5);
+
+   result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+   SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+   0xb2, value, NULL, 0, 1000);
+   if (result < 0)
+   goto error;
+   msleep(5);
+
+error:
+   return result;
+}
+
+static int sur40_set_preprocessor(struct sur40_state *dev, u8 value)
+{
+   u8 setting_07[2] = { 0x01, 0x00 };
+   u8 setting_17[2] = { 0x85, 0x80 };
+   int result;
+
+   if (value > 1)
+   return -ERANGE;
+
+   result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+   SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+   0x07, setting_07[value], NULL, 0, 1000);
+   if (result < 0)
+   goto error;
+   msleep(5);
+
+   result = usb_control_msg(dev->usbdev, usb_sndctrlpipe(dev->usbdev, 0),
+   SUR40_POKE, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+   0x17, setting_17[value], NULL, 0, 1000);
+   if (result < 0)
+   goto error;
+   msleep(5);
+
+error:
+   return result;
+}
+
+static void sur40_set_vsvideo(struct sur40_state *handle, u8 value)
+{
+   int i;
+
+   for (i = 0; i < 4; i++)
+   sur40_poke(handle, 0x1c+i, value);
+   handle->vsvideo = value;
+}
+
+static void sur40_set_irlevel(struct sur40_state *handle, u8 value)
+{
+   int i;
+
+   for (i = 0; i < 8; i++)
+   sur40_poke(handle, 0x08+(2*i), value);
+}
+
 /* Initialization routine, called from sur40_open */
 static int sur40_init(struct sur40_state *dev)
 {
-- 
2.7.4



[PATCH 1/4] add missing blob structure field for tag id

2018-02-07 Thread Florian Echtler
The SUR40 can recognize specific printed patterns directly in hardware;
this information (i.e. the pattern id) is present but currently unused
in the blob structure.

Signed-off-by: Florian Echtler 
---
 drivers/input/touchscreen/sur40.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/sur40.c 
b/drivers/input/touchscreen/sur40.c
index f16f835..8375b06 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -81,7 +81,10 @@ struct sur40_blob {
 
__le32 area;   /* size in pixels/pressure (?) */
 
-   u8 padding[32];
+   u8 padding[24];
+
+   __le32 tag_id; /* valid when type == 0x04 (SUR40_TAG) */
+   __le32 unknown;
 
 } __packed;
 
-- 
2.7.4



[PATCH 2/4] add default settings and module parameters for video controls

2018-02-07 Thread Florian Echtler
This patch adds parameter definitions and module parameters for the four
userspace controls that the SUR40 can currently provide.

Signed-off-by: Florian Echtler 
---
 drivers/input/touchscreen/sur40.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/input/touchscreen/sur40.c 
b/drivers/input/touchscreen/sur40.c
index 8375b06..8a5b031 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -149,6 +149,34 @@ struct sur40_image_header {
 #define SUR40_TOUCH0x02
 #define SUR40_TAG  0x04
 
+/* video controls */
+#define SUR40_BRIGHTNESS_MAX 0xFF
+#define SUR40_BRIGHTNESS_MIN 0x00
+#define SUR40_BRIGHTNESS_DEF 0xFF
+
+#define SUR40_CONTRAST_MAX 0x0F
+#define SUR40_CONTRAST_MIN 0x00
+#define SUR40_CONTRAST_DEF 0x0A
+
+#define SUR40_GAIN_MAX 0x09
+#define SUR40_GAIN_MIN 0x00
+#define SUR40_GAIN_DEF 0x08
+
+#define SUR40_BACKLIGHT_MAX 0x01
+#define SUR40_BACKLIGHT_MIN 0x00
+#define SUR40_BACKLIGHT_DEF 0x01
+
+/* module parameters */
+static uint brightness = SUR40_BRIGHTNESS_DEF;
+module_param(brightness, uint, 0644);
+MODULE_PARM_DESC(brightness, "set initial brightness");
+static uint contrast = SUR40_CONTRAST_DEF;
+module_param(contrast, uint, 0644);
+MODULE_PARM_DESC(contrast, "set initial contrast");
+static uint gain = SUR40_GAIN_DEF;
+module_param(gain, uint, 0644);
+MODULE_PARM_DESC(gain, "set initial gain");
+
 static const struct v4l2_pix_format sur40_pix_format[] = {
{
.pixelformat = V4L2_TCH_FMT_TU08,
-- 
2.7.4



[PATCH 4/4] add video control handlers using V4L2 control framework

2018-02-07 Thread Florian Echtler
This patch registers four standard control handlers using the corresponding
V4L2 framework.

Signed-off-by: Florian Echtler 
---
 drivers/input/touchscreen/sur40.c | 64 +++
 1 file changed, 64 insertions(+)

diff --git a/drivers/input/touchscreen/sur40.c 
b/drivers/input/touchscreen/sur40.c
index d6fa25e..b92325b 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -209,6 +210,7 @@ struct sur40_state {
struct video_device vdev;
struct mutex lock;
struct v4l2_pix_format pix_fmt;
+   struct v4l2_ctrl_handler ctrls;
 
struct vb2_queue queue;
struct list_head buf_list;
@@ -218,6 +220,7 @@ struct sur40_state {
struct sur40_data *bulk_in_buffer;
size_t bulk_in_size;
u8 bulk_in_epaddr;
+   u8 vsvideo;
 
char phys[64];
 };
@@ -231,6 +234,11 @@ struct sur40_buffer {
 static const struct video_device sur40_video_device;
 static const struct vb2_queue sur40_queue;
 static void sur40_process_video(struct sur40_state *sur40);
+static int sur40_s_ctrl(struct v4l2_ctrl *ctrl);
+
+static const struct v4l2_ctrl_ops sur40_ctrl_ops = {
+   .s_ctrl = sur40_s_ctrl,
+};
 
 /*
  * Note: an earlier, non-public version of this driver used USB_RECIP_ENDPOINT
@@ -737,6 +745,36 @@ static int sur40_probe(struct usb_interface *interface,
sur40->vdev.queue = &sur40->queue;
video_set_drvdata(&sur40->vdev, sur40);
 
+   /* initialize the control handler for 4 controls */
+   v4l2_ctrl_handler_init(&sur40->ctrls, 4);
+   sur40->v4l2.ctrl_handler = &sur40->ctrls;
+   sur40->vsvideo = (SUR40_CONTRAST_DEF << 4) | SUR40_GAIN_DEF;
+
+   v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_BRIGHTNESS,
+ SUR40_BRIGHTNESS_MIN, SUR40_BRIGHTNESS_MAX, 1, clamp(brightness,
+ (uint)SUR40_BRIGHTNESS_MIN, (uint)SUR40_BRIGHTNESS_MAX));
+
+   v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_CONTRAST,
+ SUR40_CONTRAST_MIN, SUR40_CONTRAST_MAX, 1, clamp(contrast,
+ (uint)SUR40_CONTRAST_MIN, (uint)SUR40_CONTRAST_MAX));
+
+   v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_GAIN,
+ SUR40_GAIN_MIN, SUR40_GAIN_MAX, 1, clamp(gain,
+ (uint)SUR40_GAIN_MIN, (uint)SUR40_GAIN_MAX));
+
+   v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops,
+ V4L2_CID_BACKLIGHT_COMPENSATION, SUR40_BACKLIGHT_MIN,
+ SUR40_BACKLIGHT_MAX, 1, SUR40_BACKLIGHT_DEF);
+
+   v4l2_ctrl_handler_setup(&sur40->ctrls);
+
+   if (sur40->ctrls.error) {
+   dev_err(&interface->dev,
+   "Unable to register video controls.");
+   v4l2_ctrl_handler_free(&sur40->ctrls);
+   goto err_unreg_v4l2;
+   }
+
error = video_register_device(&sur40->vdev, VFL_TYPE_TOUCH, -1);
if (error) {
dev_err(&interface->dev,
@@ -769,6 +807,7 @@ static void sur40_disconnect(struct usb_interface 
*interface)
 {
struct sur40_state *sur40 = usb_get_intfdata(interface);
 
+   v4l2_ctrl_handler_free(&sur40->ctrls);
video_unregister_device(&sur40->vdev);
v4l2_device_unregister(&sur40->v4l2);
 
@@ -962,6 +1001,31 @@ static int sur40_vidioc_g_fmt(struct file *file, void 
*priv,
return 0;
 }
 
+static int sur40_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct sur40_state *sur40  = container_of(ctrl->handler,
+ struct sur40_state, ctrls);
+   u8 value = sur40->vsvideo;
+
+   switch (ctrl->id) {
+   case V4L2_CID_BRIGHTNESS:
+   sur40_set_irlevel(sur40, ctrl->val);
+   break;
+   case V4L2_CID_CONTRAST:
+   value = (value & 0x0F) | (ctrl->val << 4);
+   sur40_set_vsvideo(sur40, value);
+   break;
+   case V4L2_CID_GAIN:
+   value = (value & 0xF0) | (ctrl->val);
+   sur40_set_vsvideo(sur40, value);
+   break;
+   case V4L2_CID_BACKLIGHT_COMPENSATION:
+   sur40_set_preprocessor(sur40, ctrl->val);
+   break;
+   }
+   return 0;
+}
+
 static int sur40_ioctl_parm(struct file *file, void *priv,
struct v4l2_streamparm *p)
 {
-- 
2.7.4



Re: [PATCH v5 03/16] media: rkisp1: Add user space ABI definitions

2018-02-07 Thread Robin Murphy

On 06/02/18 13:14, Hans Verkuil wrote:
[...]

The one thing that I worry about is if these structs are the same for
32 and 64 bit arm.


I see some enums and bools in there - in general the storage size of 
those isn't even guaranteed to be consistent between different compiler 
implementations on the same platform, let alone across multiple 
platforms (especially WRT things like GCC's -fshort-enums).


In practice, under the standard ABIs for 32-bit and 64-bit Arm[1], I'd 
expect basic types other than longs and pointers to be pretty much the 
same; it's the imp-def C stuff I'd be a lot less confident about.


Robin.

[1]:http://infocenter.arm.com/help/topic/com.arm.doc.subset.swdev.abi/index.html


Re: [PATCH 2/2] drm: adv7511: Add support for i2c_new_secondary_device

2018-02-07 Thread Kieran Bingham
Hi Archit,

Thank you for your review,

On 29/01/18 04:11, Archit Taneja wrote:
> Hi,
> 
> On 01/22/2018 06:20 PM, Kieran Bingham wrote:
>> The ADV7511 has four 256-byte maps that can be accessed via the main I²C
>> ports. Each map has it own I²C address and acts as a standard slave
>> device on the I²C bus.
>>
>> Allow a device tree node to override the default addresses so that
>> address conflicts with other devices on the same bus may be resolved at
>> the board description level.
>>
>> Signed-off-by: Kieran Bingham 
>> ---
>>   .../bindings/display/bridge/adi,adv7511.txt    | 10 +-
>>   drivers/gpu/drm/bridge/adv7511/adv7511.h   |  4 +++
>>   drivers/gpu/drm/bridge/adv7511/adv7511_drv.c   | 36 
>> ++
>>   3 files changed, 37 insertions(+), 13 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
>> b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
>> index 0047b1394c70..f6bb9f6d3f48 100644
>> --- a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
>> +++ b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
>> @@ -70,6 +70,9 @@ Optional properties:
>>     rather than generate its own timings for HDMI output.
>>   - clocks: from common clock binding: reference to the CEC clock.
>>   - clock-names: from common clock binding: must be "cec".
>> +- reg-names : Names of maps with programmable addresses.
>> +    It can contain any map needing a non-default address.
>> +    Possible maps names are : "main", "edid", "cec", "packet"
>>     Required nodes:
>>   @@ -88,7 +91,12 @@ Example
>>     adv7511w: hdmi@39 {
>>   compatible = "adi,adv7511w";
>> -    reg = <39>;
>> +    /*
>> + * The EDID page will be accessible on address 0x66 on the i2c
>> + * bus. All other maps continue to use their default addresses.
>> + */
>> +    reg = <0x39 0x66>;
>> +    reg-names = "main", "edid";
>>   interrupt-parent = <&gpio3>;
>>   interrupts = <29 IRQ_TYPE_EDGE_FALLING>;
>>   clocks = <&cec_clock>;
>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> b/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> index d034b2cb5eee..7d81ce3808e0 100644
>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> @@ -53,8 +53,10 @@
>>   #define ADV7511_REG_POWER    0x41
>>   #define ADV7511_REG_STATUS    0x42
>>   #define ADV7511_REG_EDID_I2C_ADDR    0x43
>> +#define ADV7511_REG_EDID_I2C_ADDR_DEFAULT    0x3f
>>   #define ADV7511_REG_PACKET_ENABLE1    0x44   
>>   #define ADV7511_REG_PACKET_I2C_ADDR    0x45
>> +#define ADV7511_REG_PACKET_I2C_ADDR_DEFAULT    0x38
>>   #define ADV7511_REG_DSD_ENABLE    0x46
>>   #define ADV7511_REG_VIDEO_INPUT_CFG2    0x48
>>   #define ADV7511_REG_INFOFRAME_UPDATE    0x4a
>> @@ -89,6 +91,7 @@
>>   #define ADV7511_REG_TMDS_CLOCK_INV    0xde
>>   #define ADV7511_REG_ARC_CTRL    0xdf
>>   #define ADV7511_REG_CEC_I2C_ADDR    0xe1
>> +#define ADV7511_REG_CEC_I2C_ADDR_DEFAULT    0x3c
> 
> Minor comment: The defines above make look like new register
> defines. It would be nice to remove the "REG_" from them, and
> place them somewhere after the register definitions.


Sure.


>>   #define ADV7511_REG_CEC_CTRL    0xe2
>>   #define ADV7511_REG_CHIP_ID_HIGH    0xf5
>>   #define ADV7511_REG_CHIP_ID_LOW    0xf6
>> @@ -322,6 +325,7 @@ struct adv7511 {
>>   struct i2c_client *i2c_main;
>>   struct i2c_client *i2c_edid;
>>   struct i2c_client *i2c_cec;
>> +    struct i2c_client *i2c_packet;
>>     struct regmap *regmap;
>>   struct regmap *regmap_cec;
>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>> b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>> index efa29db5fc2b..7ec33837752b 100644
>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
>> @@ -969,8 +969,8 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv)
>>   {
>>   int ret;
>>   -    adv->i2c_cec = i2c_new_dummy(adv->i2c_main->adapter,
>> - adv->i2c_main->addr - 1);
> 
> This patch avoids deriving the CEC/EDID map addresses from the main map. I 
> think
> this would break what the original patch tried to do:

That was intentional.

The ADV7511 data-sheet defines default addresses for these maps.
 (or rather the hardware does)

> 
> d25a4cbba4b9da7c2d674b2f8ecf84af1b24988e
> "drm/bridge: adv7511: add support for the 2nd chip"
> 
> Maybe the default macros can be a function of the main address?

I'm loathed to do that, because then intrinsic knowledge must be known that if I
define a device at address X ... it will also use magic offset A B and C.

IMO - the driver should define the defaults to match the hardware.

Anything else is an override ...





>> +    adv->i2c_cec = i2c_new_secondary_device(adv->i2c_main, "cec",
>> +  

Re: [PATCH v5 03/16] media: rkisp1: Add user space ABI definitions

2018-02-07 Thread Hans Verkuil
On 12/29/17 08:52, Shunqian Zheng wrote:
> From: Jeffy Chen 
> 
> Add the header for userspace

General note: I saw four cases where this documentation referred to the
datasheet. Three comments on that:

1) You don't say which datasheet.
2) I assume the datasheet is under NDA?
3) You do need to give enough information so a reasonable default can be
   used. I mentioned in an earlier review that creating an initial params
   struct that can be used as a templete would be helpful (or even
   required), and that would be a good place to put such defaults.

Regards,

Hans


Re: [RFCv3 01/17] media: add request API core and UAPI

2018-02-07 Thread Sakari Ailus
Hi Alexandre,

On Wed, Feb 07, 2018 at 10:48:05AM +0900, Alexandre Courbot wrote:
> The request API provides a way to group buffers and device parameters
> into units of work to be queued and executed. This patch introduces the
> UAPI and core framework.
> 
> This patch is based on the previous work by Laurent Pinchart. The core
> has changed considerably, but the UAPI is mostly untouched.

Thanks for the rebase.

What's the purpose of the split between media-request.c and
media-request-mgr.c? The use of ops for the request manager suggests it
could be replaced by an alternative implementation but then again the media
request is almost entirely initialised in the media-request-mgr. Either
could make some sense but not both --- I'd simply move the code from the
media-request-mgr to the functions calling them in media-request.c. That
should make this easier to read, too.

A few more comments below.

> 
> Signed-off-by: Alexandre Courbot 
> ---
>  drivers/media/Makefile   |   3 +-
>  drivers/media/media-device.c |   7 +
>  drivers/media/media-request-mgr.c| 105 
>  drivers/media/media-request.c| 311 
> +++
>  drivers/media/v4l2-core/v4l2-ioctl.c |   2 +-
>  include/media/media-device.h |   3 +
>  include/media/media-entity.h |   9 +
>  include/media/media-request-mgr.h|  73 
>  include/media/media-request.h| 186 +
>  include/uapi/linux/media.h   |  10 ++
>  10 files changed, 707 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/media/media-request-mgr.c
>  create mode 100644 drivers/media/media-request.c
>  create mode 100644 include/media/media-request-mgr.h
>  create mode 100644 include/media/media-request.h
> 
> diff --git a/drivers/media/Makefile b/drivers/media/Makefile
> index 594b462ddf0e..06c43ddb52ea 100644
> --- a/drivers/media/Makefile
> +++ b/drivers/media/Makefile
> @@ -3,7 +3,8 @@
>  # Makefile for the kernel multimedia device drivers.
>  #
>  
> -media-objs   := media-device.o media-devnode.o media-entity.o
> +media-objs   := media-device.o media-devnode.o media-entity.o \
> +media-request.o media-request-mgr.o
>  
>  #
>  # I2C drivers should come before other drivers, otherwise they'll fail
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index e79f72b8b858..024ee81a8334 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -32,6 +32,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER
>  
> @@ -407,6 +409,7 @@ static const struct media_ioctl_info ioctl_info[] = {
>   MEDIA_IOC(ENUM_LINKS, media_device_enum_links, 
> MEDIA_IOC_FL_GRAPH_MUTEX),
>   MEDIA_IOC(SETUP_LINK, media_device_setup_link, 
> MEDIA_IOC_FL_GRAPH_MUTEX),
>   MEDIA_IOC(G_TOPOLOGY, media_device_get_topology, 
> MEDIA_IOC_FL_GRAPH_MUTEX),
> + MEDIA_IOC(REQUEST_CMD, media_device_request_cmd, 0),
>  };
>  
>  static long media_device_ioctl(struct file *filp, unsigned int cmd,
> @@ -688,6 +691,10 @@ EXPORT_SYMBOL_GPL(media_device_init);
>  
>  void media_device_cleanup(struct media_device *mdev)
>  {
> + if (mdev->req_mgr) {
> + media_request_mgr_free(mdev->req_mgr);
> + mdev->req_mgr = NULL;
> + }
>   ida_destroy(&mdev->entity_internal_idx);
>   mdev->entity_internal_idx_max = 0;
>   media_graph_walk_cleanup(&mdev->pm_count_walk);
> diff --git a/drivers/media/media-request-mgr.c 
> b/drivers/media/media-request-mgr.c
> new file mode 100644
> index ..686e877a884b
> --- /dev/null
> +++ b/drivers/media/media-request-mgr.c
> @@ -0,0 +1,105 @@
> +/*
> + * Generic request manager implementation.
> + *
> + * Copyright (C) 2018, The Chromium OS Authors.  All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +static struct media_request *
> +media_request_alloc(struct media_request_mgr *mgr)
> +{
> + struct media_request *req;
> +
> + req = kzalloc(sizeof(*req), GFP_KERNEL);
> + if (!req)
> + return ERR_PTR(-ENOMEM);
> +
> + req->mgr = mgr;
> + req->state = MEDIA_REQUEST_STATE_IDLE;
> + kref_init(&req->kref);
> + INIT_LIST_HEAD(&req->data);
> + init_waitqueue_head(&req->complete_wait);
> + ATOMIC_INIT_NOTIFIER_HEAD(&req->submit_notif);
> + mutex_init(&req->lock);
> +
> + mutex_lock(&mgr->mutex);
> + req->id = ++mgr->req_id;

Re: [PATCH v8 0/7] TDA1997x HDMI video reciver

2018-02-07 Thread Hans Verkuil
On 02/07/18 09:22, Hans Verkuil wrote:
> On 02/07/2018 12:29 AM, Tim Harvey wrote:
>> Media Controller ioctls:
>> fail: v4l2-test-media.cpp(141): ent.function ==
>> MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
> 
> Weird, this shouldn't happen. I'll look into this a bit more.

Can you run 'mc_nextgen_test -e -i' and post the output?

It's found in contrib/test.

Thanks!

Hans


Re: [PATCH 5/5] add module parameters for default values

2018-02-07 Thread Hans Verkuil
On 02/07/18 09:33, Florian Echtler wrote:
> On 06.02.2018 22:31, Hans Verkuil wrote:
>> On 02/06/2018 10:01 PM, Florian Echtler wrote:
>>> To allow setting custom parameters for the sensor directly at startup, the
>>> three primary controls are exposed as module parameters in this patch.
>>>
>>> +/* module parameters */
>>> +static uint brightness = SUR40_BRIGHTNESS_DEF;
>>> +module_param(brightness, uint, 0644);
>>> +MODULE_PARM_DESC(brightness, "set default brightness");
>>> +static uint contrast = SUR40_CONTRAST_DEF;
>>> +module_param(contrast, uint, 0644);
>>> +MODULE_PARM_DESC(contrast, "set default contrast");
>>> +static uint gain = SUR40_GAIN_DEF;
>>> +module_param(gain, uint, 0644);
>>> +MODULE_PARM_DESC(contrast, "set default gain");
>>
>> contrast -> gain
> 
> Ah, typo. Thanks, will fix that.
> 
>> Isn't 'initial gain' better than 'default gain'?
> 
> Probably correct, yes.
> 
>> If I load this module with gain=X, will the gain control also
>> start off at X? I didn't see any code for that.
> 
> This reminds me: how can I get/set the control from inside the driver?
> Should I use something like the following:
> 
> struct v4l2_ctrl *ctrl = v4l2_ctrl_find(&sur40->ctrls, V4L2_CID_BRIGHTNESS);
> int val = v4l2_ctrl_g_ctrl(ctrl);
> // modify val...
> v4l2_ctrl_s_ctrl(ctrl, val);

Yes, that's correct. Usually drivers store the ctrl in their state struct
when they create the control. That way you don't have to find it.

> 
>> It might be useful to add the allowed range in the description.
>> E.g.: "set initial gain, range=0-255". Perhaps mention even the
>> default value, but I'm not sure if that's really needed.
> 
> Good point, though - right now the code directly sets the registers without 
> any
> clamping, I guess it would be better to call the control framework as 
> mentioned
> above?

Easiest is just to use this value for the default when you create the
control. Just clamp it first.

E.g.:

static uint gain = SUR40_GAIN_DEF;
module_param(gain, uint, 0644);

...

gain = clamp(gain, SUR40_GAIN_MIN, SUR40_GAIN_MAX);
v4l2_ctrl_new_std(&sur40->ctrls, &sur40_ctrl_ops, V4L2_CID_GAIN,
  SUR40_GAIN_MIN, SUR40_GAIN_MAX, 1, gain);

You need to clamp gain first, otherwise v4l2_ctrl_new_std would fail
if the given default value is out of range.

Regards,

Hans


BUG: unable to handle kernel NULL pointer dereference

2018-02-07 Thread rwar...@gmx.de

hallo

is someone so neat to look into this or to provide suggestions to debug
this ?


https://bugzilla.redhat.com/show_bug.cgi?id=1542562


maybe related:

https://bugzilla.kernel.org/show_bug.cgi?id=118101
https://bugzilla.kernel.org/show_bug.cgi?id=195029



--

Greeting

Ronald


Re: [PATCH] v4l2-ioctl.c: fix VIDIOC_DV_TIMINGS_CAP: don't clear pad

2018-02-07 Thread Sakari Ailus
On Tue, Feb 06, 2018 at 08:04:42PM +0100, Hans Verkuil wrote:
> The pad field should be passed on to the subdev driver, but it is cleared in
> v4l2-ioctl.c so the subdev driver always sees a 0 pad.
> 
> Found with v4l2-compliance.
> 
> Signed-off-by: Hans Verkuil 
> Reported-by: Tim Harvey 

Acked-by: Sakari Ailus 

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH 5/5] add module parameters for default values

2018-02-07 Thread Florian Echtler
On 06.02.2018 22:31, Hans Verkuil wrote:
> On 02/06/2018 10:01 PM, Florian Echtler wrote:
>> To allow setting custom parameters for the sensor directly at startup, the
>> three primary controls are exposed as module parameters in this patch.
>>
>> +/* module parameters */
>> +static uint brightness = SUR40_BRIGHTNESS_DEF;
>> +module_param(brightness, uint, 0644);
>> +MODULE_PARM_DESC(brightness, "set default brightness");
>> +static uint contrast = SUR40_CONTRAST_DEF;
>> +module_param(contrast, uint, 0644);
>> +MODULE_PARM_DESC(contrast, "set default contrast");
>> +static uint gain = SUR40_GAIN_DEF;
>> +module_param(gain, uint, 0644);
>> +MODULE_PARM_DESC(contrast, "set default gain");
>
> contrast -> gain

Ah, typo. Thanks, will fix that.

> Isn't 'initial gain' better than 'default gain'?

Probably correct, yes.

> If I load this module with gain=X, will the gain control also
> start off at X? I didn't see any code for that.

This reminds me: how can I get/set the control from inside the driver?
Should I use something like the following:

struct v4l2_ctrl *ctrl = v4l2_ctrl_find(&sur40->ctrls, V4L2_CID_BRIGHTNESS);
int val = v4l2_ctrl_g_ctrl(ctrl);
// modify val...
v4l2_ctrl_s_ctrl(ctrl, val);

> It might be useful to add the allowed range in the description.
> E.g.: "set initial gain, range=0-255". Perhaps mention even the
> default value, but I'm not sure if that's really needed.

Good point, though - right now the code directly sets the registers without any
clamping, I guess it would be better to call the control framework as mentioned
above?

Best regards, Florian
-- 
SENT FROM MY DEC VT50 TERMINAL



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 1/5] add missing blob structure field for tag id

2018-02-07 Thread Florian Echtler
On 06.02.2018 22:22, Hans Verkuil wrote:
> On 02/06/2018 10:01 PM, Florian Echtler wrote:
>> The SUR40 can recognize specific printed patterns directly in hardware;
>> this information (i.e. the pattern id) is present but currently unused
>> in the blob structure.
>>
>>  
>>  __le32 area;   /* size in pixels/pressure (?) */
>>  
>> -u8 padding[32];
>> +u8 padding[24];
>> +
>> +__le32 tag_id; /* valid when type == 0x04 (SUR40_TAG) */
>> +__le32 unknown;
>>  
>>  } __packed;
>>  
> Usually new fields are added before the padding, not after.
> 
> Unless there is a good reason for this I'd change this.

This is how the hardware sends it, so there's little choice in how to arrange
the fields...

Best regards, Florian
-- 
SENT FROM MY DEC VT50 TERMINAL



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v8 0/7] TDA1997x HDMI video reciver

2018-02-07 Thread Hans Verkuil
On 02/07/2018 12:29 AM, Tim Harvey wrote:
> On Tue, Feb 6, 2018 at 1:21 PM, Hans Verkuil  wrote:
>> On 02/06/2018 09:27 PM, Tim Harvey wrote:
>>
>> 
>>
>>> v4l2-compliance test results:
>>>  - with the following kernel patches:
>>>v4l2-subdev: clear reserved fields
>>>  . v4l2-subdev: without controls return -ENOTTY
>>>
>>> v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8
>>> Media Driver Info:
>>>   Driver name  : imx-media
>>>   Model: imx-media
>>>   Serial   :
>>>   Bus info :
>>>   Media version: 4.15.0
>>>   Hardware revision: 0x (0)
>>>   Driver version   : 4.15.0
>>> Interface Info:
>>>   ID   : 0x038f
>>>   Type : V4L Sub-Device
>>> Entity Info:
>>>   ID   : 0x0003 (3)
>>>   Name : tda19971 2-0048
>>>   Function : Unknown
>>
>> This is missing. It should be one of these:
>>
>> https://hverkuil.home.xs4all.nl/spec/uapi/mediactl/media-types.html#media-entity-type
>>
>> However, we don't have a proper function defined.
>>
>> I would suggest adding a new MEDIA_ENT_F_DTV_DECODER analogous to 
>> MEDIA_ENT_F_ATV_DECODER.
>>
>> It would be a new patch adding this + documentation.
> 
> Hows this look for adding to my next series:
> 
> Author: Tim Harvey 
> Date:   Tue Feb 6 14:12:52 2018 -0800
> 
> [media] add digital video decoder video interface entity functions
> 
> Add a new media entity function definition for digital TV decoders:
> MEDIA_ENT_F_DTV_DECODER
> 
> Signed-off-by: Tim Harvey 
> 
> --- a/Documentation/media/uapi/mediactl/media-types.rst
> +++ b/Documentation/media/uapi/mediactl/media-types.rst
> @@ -321,6 +321,17 @@ Types and flags used to represent the media graph 
> elements
>   MIPI CSI-2, ...), and outputs them on its source pad to an output
>   video bus of another type (eDP, MIPI CSI-2, parallel, ...).
> 
> +-  ..  row 31
> +
> +   ..  _MEDIA-ENT-F-DTV-DECODER:
> +
> +   -  ``MEDIA_ENT_F_DTV_DECODER``
> +
> +   -  Digital video decoder. The basic function of the video decoder is
> + to accept digital video from a wide variety of sources
> + and output it in some digital video standard, with appropriate
> + timing signals.
> +
>  ..  tabularcolumns:: |p{5.5cm}|p{12.0cm}|
> 
>  .. _media-entity-flag:
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index b9b9446..6653e88 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -152,6 +152,7 @@ struct media_device_info {
>   * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
>   */
>  #define MEDIA_ENT_F_TUNER  (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
> +#define MEDIA_ENT_F_DTV_DECODER
> (MEDIA_ENT_F_OLD_SUBDEV_BASE + 6)

Don't use MEDIA_ENT_F_OLD_SUBDEV_BASE for new functions.

Use this instead:

/*
 * Analog video decoder functions
 */
#define MEDIA_ENT_F_DTV_DECODER (MEDIA_ENT_F_BASE + 0x6001)

Other than this, this patch looks great.

> 
>  #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWNMEDIA_ENT_F_OLD_SUBDEV_BASE
> 
> 
> Assigning this now shows a function but does not resolve the media
> compliance results:
> 
> --- a/drivers/media/i2c/tda1997x.c
> +++ b/drivers/media/i2c/tda1997x.c
> @@ -2586,6 +2586,7 @@ static int tda1997x_probe(struct i2c_client *client,
>  id->name, i2c_adapter_id(client->adapter),
>  client->addr);
> sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
> +   sd->entity.function = MEDIA_ENT_F_DTV_DECODER;
> sd->entity.ops = &tda1997x_media_ops;
> 
> /* set allowed mbus modes based on chip, bus-type, and bus-width */
> 
> 
> root@ventana:~# v4l2-compliance -u1
> v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8
> Media Driver Info:
> Driver name  : imx-media
> Model: imx-media
> Serial   :
> Bus info :
> Media version: 4.15.0
> Hardware revision: 0x (0)
> Driver version   : 4.15.0
> Interface Info:
> ID   : 0x038f
> Type : V4L Sub-Device
> Entity Info:
> ID   : 0x0003 (3)
> Name : tda19971 2-0048
> Function : Unknown (00020006)

Actually it does. The value above is now the new function.

> Pad 0x0104   : Source
>   Link 0x026f: to remote pad 0x163 of entity
> 'ipu1_csi0_mux': Data
> 
> ...
> 
> root@ventana:~# v4l2-compliance -m0 -M
> v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8
> Media Driver Info:
> Driver name  : imx-media
> Model: imx-media
> Serial   :
> Bus info :
> Media version: 4.15.0
> Hardware revision: 0x (0)
> Driver version   : 4.15.0
>