Re: v4l2-fwnode: status, plans for merge, any branch to merge against?

2017-07-05 Thread Sakari Ailus
On Tue, Jul 04, 2017 at 05:08:19PM +0200, Pavel Machek wrote:
> Hi!
> 
> > > > > Are there any news about the fwnode branch?
> > > > > 
> > > > > I have quite usable camera, but it is still based on
> > > > > 982e8e40390d26430ef106fede41594139a4111c (that's v4.10). It would be
> > > > > good to see fwnode stuff upstream... are there any plans for that?
> > > > > 
> > > > > Is there stable branch to which I could move the stuff?
> > > > 
> > > > What's relevant for most V4L2 drivers is in linux-media right now.
> > > > 
> > > > There are new features that will take some time to get in. The trouble 
> > > > has
> > > > been, and continue to be, that the patches need to go through various 
> > > > trees
> > > > so it'll take some time for them to be merged.
> > > > 
> > > > I expect to have most of them in during the next merge window.
> > > 
> > > So git://linuxtv.org/media_tree.git branch master is the right one to
> > > work one?
> > 
> > I also pushed the rebased ccp2 branch there:
> > 
> > 
> > 
> > It's now right on the top of media-tree master.
> 
> Is ccp2 branch expected to go into 4.13, too?

Hi Pavel,

What I've done is just rebased the ccp2 branch. In other words, the patches
in that branch are no more ready than they were.

To get these merged we should ideally

1) Make sure there will be no regressions,

2) clean things up in the omap3isp; which resources are needed and when
(e.g. regulators, PHY configuration) isn't clear at the moment and

2) have one driver using the implementation.

At least 1) is needed. I think a number of framework patches could be
mergeable before 2) and 3) are done. I can prepare a set later this week.
But even that'd be likely for 4.14, not 4.13.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk


[PATCH] staging: media: atomisp: i2c: ov5693: Fix style a coding style issue

2017-07-05 Thread Ivan Menshykov
Fix checkpath errors

Signed-off-by: Ivan Menshykov 
---
 drivers/staging/media/atomisp/i2c/ov5693/ov5693.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c 
b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c
index 5e9dafe7cc32..0616ff044f1e 100644
--- a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c
+++ b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c
@@ -146,7 +146,7 @@ static int ov5693_read_reg(struct i2c_client *client,
return -EINVAL;
}
 
-   memset(msg, 0 , sizeof(msg));
+   memset(msg, 0, sizeof(msg));
 
msg[0].addr = client->addr;
msg[0].flags = 0;
@@ -702,7 +702,7 @@ static long ov5693_s_exposure(struct v4l2_subdev *sd,
 }
 
 static int ov5693_read_otp_reg_array(struct i2c_client *client, u16 size,
-u16 addr, u8 * buf)
+u16 addr, u8 *buf)
 {
u16 index;
int ret;
@@ -720,7 +720,7 @@ static int ov5693_read_otp_reg_array(struct i2c_client 
*client, u16 size,
return 0;
 }
 
-static int __ov5693_otp_read(struct v4l2_subdev *sd, u8 * buf)
+static int __ov5693_otp_read(struct v4l2_subdev *sd, u8 *buf)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct ov5693_device *dev = to_ov5693_sensor(sd);
-- 
2.13.0



[PATCH 0/2] add support for Spreadtrum's FM driver

2017-07-05 Thread Chunyan Zhang
[add linux-media list and Mauro Carvalho Chehab]

According to GregKH's suggestion [1], we tried to simply sort out the
FM driver source code which has been using in the internal projects.

Hopes it can help for fixing the problem raised in [1].

[1] https://lkml.org/lkml/2017/6/28/222

Chunyan Zhang (2):
  arm64: dts: add Spreadtrum's fm support
  misc: added Spreadtrum's radio driver

 arch/arm64/boot/dts/sprd/sp9860g-1h10.dts  |4 +
 drivers/misc/Kconfig   |1 +
 drivers/misc/Makefile  |1 +
 drivers/misc/sprd-wcn/Kconfig  |   14 +
 drivers/misc/sprd-wcn/Makefile |1 +
 drivers/misc/sprd-wcn/radio/Kconfig|8 +
 drivers/misc/sprd-wcn/radio/Makefile   |2 +
 drivers/misc/sprd-wcn/radio/fmdrv.h|  595 +++
 drivers/misc/sprd-wcn/radio/fmdrv_main.c   | 1245 
 drivers/misc/sprd-wcn/radio/fmdrv_main.h   |  117 +++
 drivers/misc/sprd-wcn/radio/fmdrv_ops.c|  447 +
 drivers/misc/sprd-wcn/radio/fmdrv_ops.h|   17 +
 drivers/misc/sprd-wcn/radio/fmdrv_rds_parser.c |  753 ++
 drivers/misc/sprd-wcn/radio/fmdrv_rds_parser.h |  103 ++
 14 files changed, 3308 insertions(+)
 create mode 100644 drivers/misc/sprd-wcn/Kconfig
 create mode 100644 drivers/misc/sprd-wcn/Makefile
 create mode 100644 drivers/misc/sprd-wcn/radio/Kconfig
 create mode 100644 drivers/misc/sprd-wcn/radio/Makefile
 create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv.h
 create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_main.c
 create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_main.h
 create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_ops.c
 create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_ops.h
 create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_rds_parser.c
 create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_rds_parser.h

-- 
2.7.4



Re: [PATCH 2/2] misc: added Spreadtrum's radio driver

2017-07-05 Thread Chunyan Zhang
On 4 July 2017 at 18:51, Arnd Bergmann  wrote:
> On Tue, Jul 4, 2017 at 12:15 PM, Chunyan Zhang
>  wrote:
>> This patch added FM radio driver for Spreadtrum's SC2342, which's
>> a WCN SoC, also added a new directory for Spreadtrum's WCN SoCs.
>>
>> Signed-off-by: Songhe Wei 
>> Signed-off-by: Chunyan Zhang 
>
> (adding linux-media folks to Cc)

(You forgot to add them in :))

>
> Hi Chunyan,

Hi Arnd,

>
> Thanks for posting this for inclusion as Greg asked for. I'm not sure what
> the policy is for new radio drivers, but I assume this would have to go
> to drivers/staging/media/ as it is a driver for hardware that fits into
> drivers/media/radio but doesn't use the respective APIs.

Ok, I agree to let it go to drivers/staging/media/.

Like I mentioned, SC2342 includes many functions, this patch is only
adding FM radio function included in SC2342 to the kernel tree.  So I
figure that its lifetime probably will not be too long, will remove it
from the kernel tree when we have a clean enough version of the whole
SC2342 drivers for the official upstreaming.

Thanks,
Chunyan

>
> Arnd
> ---
> end of message, full patch quoted for reference below
>


Re: [PATCH 2/2] misc: added Spreadtrum's radio driver

2017-07-05 Thread Arnd Bergmann
On Wed, Jul 5, 2017 at 12:18 PM, Chunyan Zhang  wrote:
> On 4 July 2017 at 18:51, Arnd Bergmann  wrote:
>> On Tue, Jul 4, 2017 at 12:15 PM, Chunyan Zhang
> Like I mentioned, SC2342 includes many functions, this patch is only
> adding FM radio function included in SC2342 to the kernel tree.  So I
> figure that its lifetime probably will not be too long, will remove it
> from the kernel tree when we have a clean enough version of the whole
> SC2342 drivers for the official upstreaming.

Would it make sense to add some or all of the other drivers to drivers/staging/
as well in the meantime?

   Arnd


[PATCH 1/3] [media] ov5645: Set media entity function

2017-07-05 Thread Todor Tomov
Set media entity function to MEDIA_ENT_F_CAM_SENSOR.

Signed-off-by: Todor Tomov 
---
 drivers/media/i2c/ov5645.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index d1e844f..bb3dd0d 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1229,6 +1229,7 @@ static int ov5645_probe(struct i2c_client *client,
ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
ov5645->pad.flags = MEDIA_PAD_FL_SOURCE;
ov5645->sd.dev = >dev;
+   ov5645->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
ret = media_entity_pads_init(>sd.entity, 1, >pad);
if (ret < 0) {
-- 
1.9.1



[PATCH 2/3] [media] ov5645: Add control to export pixel clock frequency

2017-07-05 Thread Todor Tomov
Add suport for standard V4L2_CID_PIXEL_RATE control. The pixel clock
frequency value is specific for each sensor mode so the sensor mode
structure is extended to add this. The control is read-only and its
value is updated when the sensor mode is changed - on set_format.

Signed-off-by: Todor Tomov 
---
 drivers/media/i2c/ov5645.c | 26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index bb3dd0d..4583f66 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -80,6 +80,7 @@ struct ov5645_mode_info {
u32 height;
const struct reg_value *data;
u32 data_size;
+   u32 pixel_clock;
 };
 
 struct ov5645 {
@@ -99,6 +100,7 @@ struct ov5645 {
const struct ov5645_mode_info *current_mode;
 
struct v4l2_ctrl_handler ctrls;
+   struct v4l2_ctrl *pixel_clock;
 
/* Cached register values */
u8 aec_pk_manual;
@@ -510,19 +512,22 @@ static inline struct ov5645 *to_ov5645(struct v4l2_subdev 
*sd)
.width = 1280,
.height = 960,
.data = ov5645_setting_sxga,
-   .data_size = ARRAY_SIZE(ov5645_setting_sxga)
+   .data_size = ARRAY_SIZE(ov5645_setting_sxga),
+   .pixel_clock = 11144
},
{
.width = 1920,
.height = 1080,
.data = ov5645_setting_1080p,
-   .data_size = ARRAY_SIZE(ov5645_setting_1080p)
+   .data_size = ARRAY_SIZE(ov5645_setting_1080p),
+   .pixel_clock = 16716
},
{
.width = 2592,
.height = 1944,
.data = ov5645_setting_full,
-   .data_size = ARRAY_SIZE(ov5645_setting_full)
+   .data_size = ARRAY_SIZE(ov5645_setting_full),
+   .pixel_clock = 16716
},
 };
 
@@ -969,6 +974,7 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *__format;
struct v4l2_rect *__crop;
const struct ov5645_mode_info *new_mode;
+   int ret;
 
__crop = __ov5645_get_pad_crop(ov5645, cfg, format->pad,
format->which);
@@ -978,8 +984,14 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
__crop->width = new_mode->width;
__crop->height = new_mode->height;
 
-   if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
+   if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
+   ret = v4l2_ctrl_s_ctrl_int64(ov5645->pixel_clock,
+new_mode->pixel_clock);
+   if (ret < 0)
+   return ret;
+
ov5645->current_mode = new_mode;
+   }
 
__format = __ov5645_get_pad_format(ov5645, cfg, format->pad,
format->which);
@@ -1197,7 +1209,7 @@ static int ov5645_probe(struct i2c_client *client,
 
mutex_init(>power_lock);
 
-   v4l2_ctrl_handler_init(>ctrls, 7);
+   v4l2_ctrl_handler_init(>ctrls, 8);
v4l2_ctrl_new_std(>ctrls, _ctrl_ops,
  V4L2_CID_SATURATION, -4, 4, 1, 0);
v4l2_ctrl_new_std(>ctrls, _ctrl_ops,
@@ -1215,6 +1227,10 @@ static int ov5645_probe(struct i2c_client *client,
 V4L2_CID_TEST_PATTERN,
 ARRAY_SIZE(ov5645_test_pattern_menu) - 1,
 0, 0, ov5645_test_pattern_menu);
+   ov5645->pixel_clock = v4l2_ctrl_new_std(>ctrls,
+   _ctrl_ops,
+   V4L2_CID_PIXEL_RATE,
+   1, INT_MAX, 1, 1);
 
ov5645->sd.ctrl_handler = >ctrls;
 
-- 
1.9.1



[PATCH 3/3] [media] ov5645: Add control to export CSI2 link frequency

2017-07-05 Thread Todor Tomov
Add suport for standard integer menu V4L2_CID_LINK_FREQ control.
The CSI2 link frequency value is specific for each sensor mode so the
sensor mode structure is extended to add this. The control is made
read-only and its value is updated when the sensor mode is changed -
on set_format.

Signed-off-by: Todor Tomov 
---
 drivers/media/i2c/ov5645.c | 30 ++
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index 4583f66..85622e4 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -81,6 +81,7 @@ struct ov5645_mode_info {
const struct reg_value *data;
u32 data_size;
u32 pixel_clock;
+   u32 link_freq;
 };
 
 struct ov5645 {
@@ -101,6 +102,7 @@ struct ov5645 {
 
struct v4l2_ctrl_handler ctrls;
struct v4l2_ctrl *pixel_clock;
+   struct v4l2_ctrl *link_freq;
 
/* Cached register values */
u8 aec_pk_manual;
@@ -507,27 +509,35 @@ static inline struct ov5645 *to_ov5645(struct v4l2_subdev 
*sd)
{ 0x4202, 0x00 }
 };
 
+static const s64 link_freq[] = {
+   22288,
+   33432
+};
+
 static const struct ov5645_mode_info ov5645_mode_info_data[] = {
{
.width = 1280,
.height = 960,
.data = ov5645_setting_sxga,
.data_size = ARRAY_SIZE(ov5645_setting_sxga),
-   .pixel_clock = 11144
+   .pixel_clock = 11144,
+   .link_freq = 0 /* an index in link_freq[] */
},
{
.width = 1920,
.height = 1080,
.data = ov5645_setting_1080p,
.data_size = ARRAY_SIZE(ov5645_setting_1080p),
-   .pixel_clock = 16716
+   .pixel_clock = 16716,
+   .link_freq = 1 /* an index in link_freq[] */
},
{
.width = 2592,
.height = 1944,
.data = ov5645_setting_full,
.data_size = ARRAY_SIZE(ov5645_setting_full),
-   .pixel_clock = 16716
+   .pixel_clock = 16716,
+   .link_freq = 1 /* an index in link_freq[] */
},
 };
 
@@ -990,6 +1000,11 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
if (ret < 0)
return ret;
 
+   ret = v4l2_ctrl_s_ctrl(ov5645->link_freq,
+  new_mode->link_freq);
+   if (ret < 0)
+   return ret;
+
ov5645->current_mode = new_mode;
}
 
@@ -1209,7 +1224,7 @@ static int ov5645_probe(struct i2c_client *client,
 
mutex_init(>power_lock);
 
-   v4l2_ctrl_handler_init(>ctrls, 8);
+   v4l2_ctrl_handler_init(>ctrls, 9);
v4l2_ctrl_new_std(>ctrls, _ctrl_ops,
  V4L2_CID_SATURATION, -4, 4, 1, 0);
v4l2_ctrl_new_std(>ctrls, _ctrl_ops,
@@ -1231,6 +1246,13 @@ static int ov5645_probe(struct i2c_client *client,
_ctrl_ops,
V4L2_CID_PIXEL_RATE,
1, INT_MAX, 1, 1);
+   ov5645->link_freq = v4l2_ctrl_new_int_menu(>ctrls,
+  _ctrl_ops,
+  V4L2_CID_LINK_FREQ,
+  ARRAY_SIZE(link_freq) - 1,
+  0, link_freq);
+   if(ov5645->link_freq)
+   ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
ov5645->sd.ctrl_handler = >ctrls;
 
-- 
1.9.1



Re: [PATCH v2 1/7] DT bindings: add bindings for ov965x camera module

2017-07-05 Thread Hugues FRUCHET

On 07/05/2017 04:03 PM, Rob Herring wrote:
> On Mon, Jul 03, 2017 at 11:16:02AM +0200, Hugues Fruchet wrote:
>> From: "H. Nikolaus Schaller" 
>>
>> This adds documentation of device tree bindings
>> for the OV965X family camera sensor module.
>>
>> Signed-off-by: H. Nikolaus Schaller 
>> Signed-off-by: Hugues Fruchet 
>> ---
>>   .../devicetree/bindings/media/i2c/ov965x.txt   | 45 
>> ++
>>   1 file changed, 45 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/media/i2c/ov965x.txt
>>
>> diff --git a/Documentation/devicetree/bindings/media/i2c/ov965x.txt 
>> b/Documentation/devicetree/bindings/media/i2c/ov965x.txt
>> new file mode 100644
>> index 000..4ceb727
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/media/i2c/ov965x.txt
>> @@ -0,0 +1,45 @@
>> +* Omnivision OV9650/9652/9655 CMOS sensor
>> +
>> +The Omnivision OV965x sensor support multiple resolutions output, such as
>> +CIF, SVGA, UXGA. It also can support YUV422/420, RGB565/555 or raw RGB
>> +output format.
>> +
>> +Required Properties:
>> +- compatible: should be one of
>> +"ovti,ov9650"
>> +"ovti,ov9652"
>> +"ovti,ov9655"
>> +- clocks: reference to the mclk input clock.
>> +
>> +Optional Properties:
>> +- resetb-gpios: reference to the GPIO connected to the RESETB pin, if any,
>> +polarity is active low.
> 
> reset-gpios
> 
>> +- pwdn-gpios: reference to the GPIO connected to the PWDN pin, if any,
>> +polarity is active high.
> 
> powerdown-gpios
> 
> Both are standardish names for such signals.
> 
> Rob

Thanks Rob, I will fix,
Hugues.

> 

Re: [PATCH v2 1/7] DT bindings: add bindings for ov965x camera module

2017-07-05 Thread Rob Herring
On Mon, Jul 03, 2017 at 11:16:02AM +0200, Hugues Fruchet wrote:
> From: "H. Nikolaus Schaller" 
> 
> This adds documentation of device tree bindings
> for the OV965X family camera sensor module.
> 
> Signed-off-by: H. Nikolaus Schaller 
> Signed-off-by: Hugues Fruchet 
> ---
>  .../devicetree/bindings/media/i2c/ov965x.txt   | 45 
> ++
>  1 file changed, 45 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/i2c/ov965x.txt
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/ov965x.txt 
> b/Documentation/devicetree/bindings/media/i2c/ov965x.txt
> new file mode 100644
> index 000..4ceb727
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/i2c/ov965x.txt
> @@ -0,0 +1,45 @@
> +* Omnivision OV9650/9652/9655 CMOS sensor
> +
> +The Omnivision OV965x sensor support multiple resolutions output, such as
> +CIF, SVGA, UXGA. It also can support YUV422/420, RGB565/555 or raw RGB
> +output format.
> +
> +Required Properties:
> +- compatible: should be one of
> + "ovti,ov9650"
> + "ovti,ov9652"
> + "ovti,ov9655"
> +- clocks: reference to the mclk input clock.
> +
> +Optional Properties:
> +- resetb-gpios: reference to the GPIO connected to the RESETB pin, if any,
> + polarity is active low.

reset-gpios

> +- pwdn-gpios: reference to the GPIO connected to the PWDN pin, if any,
> + polarity is active high.

powerdown-gpios

Both are standardish names for such signals.

Rob


[GIT PULL for v4.13-rc1] media updates

2017-07-05 Thread Mauro Carvalho Chehab
Hi Linus,

Please pull from:
  git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
tags/media/v4.13-1

For:

- Addition of fwnode support at V4L2 core;
- Addition of a few more SDR formats;
- New imx driver to support i.MX6 cameras;
- New driver for Qualcon venus codecs;
- New I2C sensor drivers: dw9714, max2175, ov13858, ov5640;
- New CEC driver: stm32-cec;
- Some Improvements at DVB frontend documentation and a few fixups;
- Several drivers improvements and fixups.

Regards,
Mauro

--


The following changes since commit 41f1830f5a7af77cf5c86359aba3cbd706687e52:

  Linux 4.12-rc6 (2017-06-19 22:19:37 +0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
tags/media/v4.13-1

for you to fetch changes up to 2a2599c663684a1142dae0bff7737e125891ae6d:

  [media] media: entity: Catch unbalanced media_pipeline_stop calls (2017-06-23 
09:23:36 -0300)


media updates for v4.13-rc1


A Sun (4):
  [media] mceusb: sporadic RX truncation corruption fix
  [media] mceusb: fix inaccurate debug buffer dumps, and misleading debug 
messages
  [media] mceusb: RX -EPIPE (urb status = -32) lockup failure fix
  [media] mceusb: TX -EPIPE (urb status = -32) lockup fix

Alan Cox (10):
  [media] atompisp: HAS_BL is never defined so lose it
  [media] atomisp: remove NUM_OF_BLS
  [media] atomisp2: remove HRT_UNSCHED
  [media] atomisp2: tidy up confused ifdefs
  [media] atomisp: eliminate dead code under HAS_RES_MGR
  [media] atomisp: unify sh_css_hmm_buffer_record_acquire
  [media] atomisp: Unify load_preview_binaries for the most part
  [media] atomisp: Unify lut free logic
  [media] atomisp: remove sh_css_irq - it contains nothing
  [media] atomisp: de-duplicate sh_css_mmu_set_page_table_base_index

Alex Deryskyba (1):
  [media] rc: meson-ir: switch config to NEC decoding on shutdown

Alexandre Courbot (2):
  [media] media-ioc-g-topology.rst: fix typos
  [media] s5p-jpeg: fix recursive spinlock acquisition

Andi Shyti (1):
  [media] rc: ir-spi: remove unnecessary initialization

Andrey Utkin (2):
  [media] MAINTAINERS: solo6x10, tw5864: add Anton Sviridenko
  [media] MAINTAINERS: solo6x10: update Andrey Utkin email

Andy Shevchenko (1):
  [media] as3645a: Join string literals back

Anton Blanchard (1):
  [media] ir-spi: Fix issues with lirc API

Antti Palosaari (15):
  [media] af9015: use correct 7-bit i2c addresses
  [media] af9013: move config values directly under driver state
  [media] af9013: add i2c client bindings
  [media] af9013: use kernel 64-bit division
  [media] af9013: fix logging
  [media] af9013: convert to regmap api
  [media] af9013: fix error handling
  [media] af9013: add dvbv5 cnr
  [media] af9015: fix and refactor i2c adapter algo logic
  [media] af9015: enable 2nd TS flow control when dual mode
  [media] af9013: add configurable TS output pin
  [media] af9013: remove unneeded register writes
  [media] af9015: move 2nd demod power-up wait different location
  [media] af9013: refactor firmware download routine
  [media] af9013: refactor power control

Arnd Bergmann (6):
  [media] rainshadow-cec: use strlcat instead of strncat
  [media] rainshadow-cec: avoid -Wmaybe-uninitialized warning
  [media] cec: improve MEDIA_CEC_RC dependencies
  [media] cec-notifier.h: handle unreachable CONFIG_CEC_CORE
  [media] ir-core: fix gcc-7 warning on bool arithmetic
  [media] dvb: don't use 'time_t' in event ioctl

Arvind Yadav (1):
  [media] tc358743: Handle return value of clk_prepare_enable

Avraham Shukron (3):
  [media] atomisp: fixed sparse warnings
  [media] atomisp: fixed coding style errors
  [media] atomisp: fix coding style warnings

Benjamin Gaignard (5):
  [media] cec: stih: allow to use max CEC logical addresses
  [media] cec: stih: fix typos in comments
  [media] dt-bindings: media: stm32 cec driver
  [media] cec: add STM32 cec driver
  [media] exynos4-is: use devm_of_platform_populate()

Chen Guanqiao (1):
  [media] staging: atomisp: lm3554: fix sparse warnings(was not declared. 
Should it be static?)

Christoph Fanelsa (1):
  [media] staging: media: cxd2099: Fix checkpatch issues

Christophe JAILLET (2):
  [media] vb2: Fix an off by one error in 'vb2_plane_vaddr'
  [media] vb2: Fix error handling in '__vb2_buf_mem_alloc'

Colin Ian King (4):
  [media] cx18: fix spelling mistake: "demodualtor" -> "demodulator"
  [media] em28xx: fix spelling mistake: "missdetected" -> "misdetected"
  [media] pvrusb2: remove redundant check on cnt > 8
  [media] s5p-mfc: fix spelling mistake: "destionation" -> "destination"

Dan Carpenter (3):
  [media] atomisp: one char read beyond end of 

Re: Trying to use IR driver for my SoC

2017-07-05 Thread Mason
On 29/06/2017 19:50, Sean Young wrote:

> The only thing that stands out is RC5_TIME_BASE. If that is the bit
> length or shortest pulse/space? In the latter case it should be 888 usec.

IR_RC5_DECODER_CLK_DIV
Length of 1 bit of the RC5 code in units of 27 MHz clks

Default value = 0xbb86  => 1.778 ms

#define RC5_TIME_BASE   1778
(time in microseconds apparently)

clkdiv = clkrate * RC5_TIME_BASE / 1e6 = 48006 = 0xbb86

I don't really see the point of reprogramming the
default value, though...

I'm thinking GPIO directions might be misconfigured, which
could explain why no IRQs are firing. Back to basics.

Regards.


[PATCH] s5k5baf: remove unnecessary static in s5k5baf_get_selection()

2017-07-05 Thread Gustavo A. R. Silva
Remove unnecessary static on local variable rtype.
Such variable is initialized before being used,
on every execution path throughout the function.
The static has no benefit and, removing it reduces
the code size.

This issue was detected using Coccinelle and the following semantic patch:

@bad exists@
position p;
identifier x;
type T;
@@

static T x@p;
...
x = <+...x...+>

@@
identifier x;
expression e;
type T;
position p != bad.p;
@@

-static
 T x@p;
 ... when != x
 when strict
?x = e;

In the following log you can see the difference in the code size. Also,
there is a significant difference in the bss segment. This log is the
output of the size command, before and after the code change:

before:
   textdata bss dec hex filename
  277655656 320   3374183cd drivers/media/i2c/s5k5baf.o

after:
   textdata bss dec hex filename
  277335600 256   335898335 drivers/media/i2c/s5k5baf.o


Signed-off-by: Gustavo A. R. Silva 
---
 drivers/media/i2c/s5k5baf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 962051b..f01722d 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -1374,7 +1374,7 @@ static int s5k5baf_get_selection(struct v4l2_subdev *sd,
 struct v4l2_subdev_pad_config *cfg,
 struct v4l2_subdev_selection *sel)
 {
-   static enum selection_rect rtype;
+   enum selection_rect rtype;
struct s5k5baf *state = to_s5k5baf(sd);
 
rtype = s5k5baf_get_sel_rect(sel->pad, sel->target);
-- 
2.5.0



Re: [PATCH v3 0/2] [media] videobuf2-dc: Add support for cacheable MMAP

2017-07-05 Thread Christoph Hellwig
On Mon, Jul 03, 2017 at 11:27:32AM +0200, Marek Szyprowski wrote:
> The main question here if we want to merge incomplete solution or not. As
> for now, there is no support in ARM/ARM64 for NON_CONSISTENT attribute.
> Also none of the v4l2 drivers use it. Sadly support for NON_CONSISTENT
> attribute is not fully implemented nor even defined in mainline.
>

DMA_ATTR_NON_CONSISTENT is the way to get the dma_alloc_noncoherent
semantics through the dma_alloc_attr API, and as such I think it is
pretty well defined, although the documentation in
Documentation/DMA-attributes.txt is really bad and we need to improve
it, by merging it with the dma_alloc_noncoherent description in
Documentation/DMA-API.txt. My series to remove dma_alloc_noncoherent
updates the latter to mention DMA_ATTR_NON_CONSISTENT, but
we should probably merge Documentation/DMA-API.txt,
Documentation/DMA-attributes.txt and Documentation/DMA-API-HOWTO.txt
into a single coherent document.


> I know that it works fine for some vendor kernel trees, but supporting it in
> mainline was a bit controversial. There is no proper way to sync cache for 
> such
> buffers. Calling dma_sync_sg worked so far, but it has to be first agreed as
> a proper DMA API.

As documented in Documentation/DMA-API.txt the proper way to sync
noncoherent/nonconsistent regions is to call dma_cache_sync.  It seems
like it generally is the same as dma_sync_range/sg so if we could
eventually merge these APIs that should reduce the confusion further.


Re: [PATCH v2] media: platform: rcar_imr: add IMR-LX3 support

2017-07-05 Thread Rob Herring
On Wed, Jun 28, 2017 at 10:58:44PM +0300, Sergei Shtylyov wrote:
> Add support for the image renderer light extended 3 (IMR-LX3) found only in
> the R-Car V2H (R8A7792) SoC. It's mostly the same as IMR-LSX3 but doesn't
> support video capture data as a source of 2D textures.
> 
> Signed-off-by: Sergei Shtylyov 
> 
> ---
> This patch  is against the 'media_tree.git' repo's 'master' branch plus the
> latest version of  the Renesas IMR driver and the patch adding IMR-LSX3 
> support.
> 
> Changes in version 2:
> - refreshed the patch atop of the IMR driver patch (version 6) and IMR-LSX3
>   patch (version 3).
> 
>  Documentation/devicetree/bindings/media/rcar_imr.txt |4 ++

Acked-by: Rob Herring 

>  drivers/media/platform/rcar_imr.c|   27 
> ---
>  2 files changed, 22 insertions(+), 9 deletions(-)


Re: [PATCH 3/3] [media] ov5645: Add control to export CSI2 link frequency

2017-07-05 Thread Sakari Ailus
On Wed, Jul 05, 2017 at 11:44:49AM +0300, Todor Tomov wrote:
> @@ -1231,6 +1246,13 @@ static int ov5645_probe(struct i2c_client *client,
>   _ctrl_ops,
>   V4L2_CID_PIXEL_RATE,
>   1, INT_MAX, 1, 1);
> + ov5645->link_freq = v4l2_ctrl_new_int_menu(>ctrls,
> +_ctrl_ops,
> +V4L2_CID_LINK_FREQ,
> +ARRAY_SIZE(link_freq) - 1,
> +0, link_freq);
> + if(ov5645->link_freq)

Thanks!

Applied the set, with the above typo fixed (i.e. space added).

> + ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
>  
>   ov5645->sd.ctrl_handler = >ctrls;
>  

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk


[PATCH] sir_ir: remove unnecessary static in sir_interrupt()

2017-07-05 Thread Gustavo A. R. Silva
Remove unnecessary static on local variable delt.
Such variable is initialized before being used,
on every execution path throughout the function.
The static has no benefit and, removing it reduces
the code size.

This issue was detected using Coccinelle and the following semantic patch:

@bad exists@
position p;
identifier x;
type T;
@@

static T x@p;
...
x = <+...x...+>

@@
identifier x;
expression e;
type T;
position p != bad.p;
@@

-static
 T x@p;
 ... when != x
 when strict
?x = e;

In the following log you can see the difference in the code size. Also,
there is a significant difference in the bss segment. This log is the
output of the size command, before and after the code change:

before:
   textdata bss dec hex filename
   50093456 57690412351 drivers/media/rc/sir_ir.o

after:
   textdata bss dec hex filename
   49883400 512890022c4 drivers/media/rc/sir_ir.o

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/media/rc/sir_ir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/sir_ir.c b/drivers/media/rc/sir_ir.c
index 20234ba..be67f7c 100644
--- a/drivers/media/rc/sir_ir.c
+++ b/drivers/media/rc/sir_ir.c
@@ -155,7 +155,7 @@ static irqreturn_t sir_interrupt(int irq, void *dev_id)
 {
unsigned char data;
ktime_t curr_time;
-   static unsigned long delt;
+   unsigned long delt;
unsigned long deltintr;
unsigned long flags;
int counter = 0;
-- 
2.5.0



Re: [PATCH v6 4/4] dt-bindings: media: Document Synopsys Designware HDMI RX

2017-07-05 Thread Sylwester Nawrocki
On 07/04/2017 04:11 PM, Jose Abreu wrote:
> Document the bindings for the Synopsys Designware HDMI RX.
> 
> Signed-off-by: Jose Abreu 

> ---
>   .../devicetree/bindings/media/snps,dw-hdmi-rx.txt  | 70 
> ++
>   1 file changed, 70 insertions(+)
>   create mode 100644 
> Documentation/devicetree/bindings/media/snps,dw-hdmi-rx.txt

Could you make the DT binding documentation patch first patch in the series?
Now checkpatch will complain about undocumented compatible string when 
the driver patches are applied alone.

> diff --git a/Documentation/devicetree/bindings/media/snps,dw-hdmi-rx.txt 
>b/Documentation/devicetree/bindings/media/snps,dw-hdmi-rx.txt
> new file mode 100644
> index 000..449b8a2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/snps,dw-hdmi-rx.txt
> @@ -0,0 +1,70 @@
> +Synopsys DesignWare HDMI RX Decoder
> +===
> +
> +This document defines device tree properties for the Synopsys DesignWare HDMI
> +RX Decoder (DWC HDMI RX). It doesn't constitute a device tree binding
> +specification by itself but is meant to be referenced by platform-specific
> +device tree bindings.
> +
> +When referenced from platform device tree bindings the properties defined in
> +this document are defined as follows.

It would be good to make it clear which properties are required and which are
optional. And also to mention the properties below belong to the HDMI RX node.

> +- compatible: Shall be "snps,dw-hdmi-rx".
> +
> +- reg: Memory mapped base address and length of the DWC HDMI RX registers.
> +
> +- interrupts: Reference to the DWC HDMI RX interrupt and 5v sense interrupt.

s/5v/HDMI 5V ?

> +
> +- clocks: Phandle to the config clock block.
> +
> +- clock-names: Shall be "cfg".
> +
> +- edid-phandle: phandle to the EDID handler block.

Could you make this property optional and when it is missing assume that device
corresponding to the parent node of this node handles EDID? This way we could
avoid having property pointing to the parent node.

> +- #address-cells: Shall be 1.
> +
> +- #size-cells: Shall be 0.
> +
> +You also have to create a subnode for phy driver. Phy properties are as 
> follows.

s/phy driver. Phy/the PHY device. PHY ?

Might be also worth to make it explicit these are all required properties.

> +- compatible: Shall be "snps,dw-hdmi-phy-e405".
> +
> +- reg: Shall be JTAG address of phy.

s/phy/the PHY ?

> +- clocks: Phandle for cfg clock.
> +
> +- clock-names:Shall be "cfg".
> +
> +A sample binding is now provided. The compatible string is for a SoC which 
> has
> +has a Synopsys DesignWare HDMI RX decoder inside.
> +
> +Example:
> +
> +dw_hdmi_soc: dw-hdmi-soc@0 {
> + compatible = "snps,dw-hdmi-soc";

Perhaps just make it

compatible = "...";
?

> + reg = <0x11c00 0x1000>; /* EDIDs */

This is not relevant and undocumented, will likely be part of documentation 
of other binding thus I'd suggest dropping this reg property.

> + #address-cells = <1>;
> + #size-cells = <1>;
> + ranges;
> +
> + hdmi-rx@0 {
> + compatible = "snps,dw-hdmi-rx";
> + reg = <0x0 0x1>;
> + interrupts = <1 2>;
> + edid-phandle = <_hdmi_soc>;
> +
> + clocks = <_hdmi_refclk>;
> + clock-names = "cfg";
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + hdmi-phy@fc {
> + compatible = "snps,dw-hdmi-phy-e405";
> + reg = <0xfc>;
> +
> + clocks = <_hdmi_refclk>;
> + clock-names = "cfg";
> + };
> + };
> +};

Otherwise looks good. I'll likely not have comments to the other patches.

--
Regards,
Sylwester
 


Re: [PATCH v6] media: platform: Renesas IMR driver

2017-07-05 Thread Sergei Shtylyov

Hello!

On 07/03/2017 03:25 PM, Hans Verkuil wrote:


From: Konstantin Kozhevnikov 

The image renderer, or the distortion correction engine, is a drawing
processor with a simple instruction system capable of referencing video
capture data or data in an external memory as the 2D texture data and
performing texture mapping and drawing with respect to any shape that is
split into triangular objects.

This V4L2 memory-to-memory device driver only supports image renderer light
extended 4 (IMR-LX4) found in the R-Car gen3 SoCs; the R-Car gen2 support
can be added later...

[Sergei: merged 2 original patches, added  the patch description, removed
unrelated parts,  added the binding document and the UAPI documentation,
ported the driver to the modern kernel, renamed the UAPI header file and
the guard macros to match the driver name, extended the copyrights, fixed
up Kconfig prompt/depends/help, made use of the BIT/GENMASK() macros,
sorted  #include's, replaced 'imr_ctx::crop' array with the 'imr_ctx::rect'
structure, replaced imr_{g|s}_crop() with imr_{g|s}_selection(), completely
rewrote imr_queue_setup(), removed 'imr_format_info::name', moved the
applicable code from imr_buf_queue() to imr_buf_prepare() and moved the
rest of imr_buf_queue() after imr_buf_finish(), assigned 'src_vq->dev' and
'dst_vq->dev' in imr_queue_init(), removed imr_start_streaming(), assigned
'src_vq->dev' and 'dst_vq->dev' in imr_queue_init(), clarified the math in
imt_tri_type_{a|b|c}_length(), clarified the pointer math and avoided casts
to 'void *' in imr_tri_set_type_{a|b|c}(), replaced imr_{reqbufs|querybuf|
dqbuf|expbuf|streamon|streamoff}() with the generic helpers, implemented
vidioc_{create_bufs|prepare_buf}() methods, used ALIGN() macro and merged
the matrix size checks and replaced kmalloc()/copy_from_user() calls with
memdup_user() call in imr_ioctl_map(), moved setting device capabilities
from imr_querycap() to imr_probe(), set the valid default queue format in
imr_probe(), removed leading dots and fixed grammar in the comments, fixed
up  the indentation  to use  tabs where possible, renamed DLSR, CMRCR.
DY1{0|2}, and ICR bits to match the manual, changed the prefixes of the
CMRCR[2]/TRI{M|C}R bits/fields to match the manual, removed non-existent
TRIMR.D{Y|U}D{X|V}M bits, added/used the IMR/{UV|CP}DPOR/SUSR bits/fields/
shifts, separated the register offset/bit #define's, sorted instruction
macros by opcode, removed unsupported LINE instruction, masked the register
address in WTL[2]/WTS instruction macros, moved the display list #define's
after the register #define's, removing the redundant comment, avoided
setting reserved bits when writing CMRCCR[2]/TRIMCR, used the SR bits
instead of a bare number, removed *inline* from .c file, fixed lines over
80 columns, removed useless spaces, comments, parens, operators, casts,
braces, variables, #include's, statements, and even 1 function, added
useful local variable, uppercased and spelled out the abbreviations,
made comment wording more consistent/correct, fixed the comment typos,
reformatted some multiline comments, inserted empty line after declaration,
removed extra empty lines,  reordered some local variable desclarations,
removed calls to 4l2_err() on kmalloc() failure, replaced '*' with 'x'
in some format strings for v4l2_dbg(), fixed the error returned by
imr_default(), avoided code duplication in the IRQ handler, used '__packed'
for the UAPI structures, declared 'imr_map_desc::data' as '__u64' instead
of 'void *', switched to '__u{16|32}' in the UAPI header, enclosed the
macro parameters in parens, exchanged the values of IMR_MAP_AUTO{S|D}G
macros.]


As Geert suggested, just replace this with a 'Based-on' line.


   OK, the list grew too long indeed. :-)





Index: media_tree/drivers/media/platform/rcar_imr.c
===
--- /dev/null
+++ media_tree/drivers/media/platform/rcar_imr.c
@@ -0,0 +1,1877 @@





+/* add reference to the current configuration */
+static struct imr_cfg *imr_cfg_ref(struct imr_ctx *ctx)


imr_cfg_ref -> imr_cfg_ref_get


   OK, but imr_cfg_get() seems a better name.


+{
+struct imr_cfg *cfg = ctx->cfg;
+
+BUG_ON(!cfg);


Perhaps this can be replaced by:

if (WARN_ON(!cfg))
return NULL;


   I'm afraid imr_device_run() will cause oops in this case...


+cfg->refcount++;
+return cfg;
+}
+
+/* mesh configuration destructor */
+static void imr_cfg_unref(struct imr_ctx *ctx, struct imr_cfg *cfg)


imr_cfg_unref -> imr_cfg_ref_put


  OK, but I'll call it imr_cfg_put().


That follows the standard naming conventions for refcounting.


+{
+struct imr_device *imr = ctx->imr;
+
+/* no atomicity is required as operation is locked with device mutex */
+if (!cfg || --cfg->refcount)
+return;
+
+/* release memory allocated for a display list */
+if (cfg->dl_vaddr)
+dma_free_writecombine(imr->dev, 

[PATCH] tuners: remove unnecessary static in simple_dvb_configure()

2017-07-05 Thread Gustavo A. R. Silva
Remove unnecessary static on local variable t_params.
Such variable is initialized before being used,
on every execution path throughout the function.
The static has no benefit and, removing it reduces
the code size.

This issue was detected using Coccinelle and the following semantic patch:

@bad exists@
position p;
identifier x;
type T;
@@

static T x@p;
...
x = <+...x...+>

@@
identifier x;
expression e;
type T;
position p != bad.p;
@@

-static
 T x@p;
 ... when != x
 when strict
?x = e;

In the following log you can see the difference in the code size. Also,
there is a significant difference in the bss segment. This log is the
output of the size command, before and after the code change:

before:
   textdata bss dec hex filename
  233143640 832   277866c8a drivers/media/tuners/tuner-simple.o

after:
   textdata bss dec hex filename
  232573552 768   275776bb9 drivers/media/tuners/tuner-simple.o

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/media/tuners/tuner-simple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/tuners/tuner-simple.c 
b/drivers/media/tuners/tuner-simple.c
index 3339b13..cf44d36 100644
--- a/drivers/media/tuners/tuner-simple.c
+++ b/drivers/media/tuners/tuner-simple.c
@@ -846,7 +846,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 
*buf,
/* This function returns the tuned frequency on success, 0 on error */
struct tuner_simple_priv *priv = fe->tuner_priv;
struct tunertype *tun = priv->tun;
-   static struct tuner_params *t_params;
+   struct tuner_params *t_params;
u8 config, cb;
u32 div;
int ret;
-- 
2.5.0



[PATCH 7/8] omap3isp: Check for valid port in endpoints

2017-07-05 Thread Sakari Ailus
Check that we do have a valid port in an endpoint, return an error if not.

Signed-off-by: Sakari Ailus 
---
 drivers/media/platform/omap3isp/isp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 2d45bf471c82..0676be725d7c 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2081,7 +2081,7 @@ static int isp_fwnode_parse(struct device *dev, struct 
fwnode_handle *fwnode,
default:
dev_warn(dev, "%s: invalid interface %u\n",
 to_of_node(fwnode)->full_name, vep.base.port);
-   break;
+   return -EINVAL;
}
 
return 0;
-- 
2.11.0



[PATCH 0/8] Prepare for CCP2 / CSI-1 support, omap3isp fixes

2017-07-05 Thread Sakari Ailus
Hi Pavel and others,

Most of these patches have been posted to the list in some form or other
already but a lot has happened since. Thus reposting. There are more
patches in my ccp2 branch but they're not quite ready as such, for the
reasons discussed previously.


Pavel Machek (1):
  smiapp: add CCP2 support

Sakari Ailus (7):
  dt: bindings: Explicitly specify bus type
  dt: bindings: Add strobe property for CCP2
  v4l: fwnode: Call CSI2 bus csi2, not csi
  v4l: fwnode: Obtain data bus type from FW
  v4l: Add support for CSI-1 and CCP2 busses
  omap3isp: Check for valid port in endpoints
  omap3isp: Destroy CSI-2 phy mutexes in error and module removal

 .../devicetree/bindings/media/video-interfaces.txt |  8 ++-
 drivers/media/i2c/smiapp/smiapp-core.c | 14 +++--
 drivers/media/platform/omap3isp/isp.c  |  8 ++-
 drivers/media/platform/omap3isp/ispcsiphy.c|  6 ++
 drivers/media/platform/omap3isp/ispcsiphy.h|  1 +
 drivers/media/platform/pxa_camera.c|  3 +
 drivers/media/platform/soc_camera/soc_mediabus.c   |  3 +
 drivers/media/v4l2-core/v4l2-fwnode.c  | 73 ++
 include/media/v4l2-fwnode.h| 19 ++
 include/media/v4l2-mediabus.h  |  4 ++
 10 files changed, 118 insertions(+), 21 deletions(-)

-- 
2.11.0



[PATCH 1/8] dt: bindings: Explicitly specify bus type

2017-07-05 Thread Sakari Ailus
From: Sakari Ailus 

In the vast majority of cases the bus type is known to the driver(s)
since a receiver or transmitter can only support a single one. There
are cases however where different options are possible, or the bus type
cannot be automatically detected.

The existing V4L2 OF support tries to figure out the bus type and
parse the bus parameters based on that. This does not scale too well
as there are multiple serial busses that share common properties.

Some hardware also supports multiple types of busses on the same
interfaces.

Signed-off-by: Sakari Ailus 
Signed-off-by: Ivaylo Dimitrov 
Signed-off-by: Pavel Machek 
Reviewed-By: Sebastian Reichel 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/media/video-interfaces.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
b/Documentation/devicetree/bindings/media/video-interfaces.txt
index 9cd2a369125d..9aa2722b6920 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.txt
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -76,6 +76,11 @@ Optional endpoint properties
   mode horizontal and vertical synchronization signals are provided to the
   slave device (data source) by the master device (data sink). In the master
   mode the data source device is also the source of the synchronization 
signals.
+- bus-type: data bus type. Possible values are:
+  0 - autodetect based on other properties (MIPI CSI-2 D-PHY, parallel or 
Bt656)
+  1 - MIPI CSI-2 C-PHY
+  2 - MIPI CSI1
+  3 - CCP2
 - bus-width: number of data lines actively used, valid for the parallel busses.
 - data-shift: on the parallel data busses, if bus-width is used to specify the
   number of data lines, data-shift can be used to specify which data lines are
-- 
2.11.0



[PATCH 8/8] omap3isp: Destroy CSI-2 phy mutexes in error and module removal

2017-07-05 Thread Sakari Ailus
The CSI-2 phy driver did initialise mutexes in its init function but there
was no corresponding cleanup function destroying them. Fix that. Also
clean up ISP module initialisation a little.

Signed-off-by: Sakari Ailus 
---
 drivers/media/platform/omap3isp/isp.c   | 6 --
 drivers/media/platform/omap3isp/ispcsiphy.c | 6 ++
 drivers/media/platform/omap3isp/ispcsiphy.h | 1 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 0676be725d7c..7028bbe13b69 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1859,6 +1859,7 @@ static void isp_cleanup_modules(struct isp_device *isp)
omap3isp_ccdc_cleanup(isp);
omap3isp_ccp2_cleanup(isp);
omap3isp_csi2_cleanup(isp);
+   omap3isp_csiphy_cleanup(isp);
 }
 
 static int isp_initialize_modules(struct isp_device *isp)
@@ -1868,7 +1869,7 @@ static int isp_initialize_modules(struct isp_device *isp)
ret = omap3isp_csiphy_init(isp);
if (ret < 0) {
dev_err(isp->dev, "CSI PHY initialization failed\n");
-   goto error_csiphy;
+   return ret;
}
 
ret = omap3isp_csi2_init(isp);
@@ -1937,7 +1938,8 @@ static int isp_initialize_modules(struct isp_device *isp)
 error_ccp2:
omap3isp_csi2_cleanup(isp);
 error_csi2:
-error_csiphy:
+   omap3isp_csiphy_cleanup(isp);
+
return ret;
 }
 
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c 
b/drivers/media/platform/omap3isp/ispcsiphy.c
index 871d4fe09c7f..83940e9d8291 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.c
+++ b/drivers/media/platform/omap3isp/ispcsiphy.c
@@ -345,3 +345,9 @@ int omap3isp_csiphy_init(struct isp_device *isp)
 
return 0;
 }
+
+void omap3isp_csiphy_cleanup(struct isp_device *isp)
+{
+   mutex_destroy(>isp_csiphy1.mutex);
+   mutex_destroy(>isp_csiphy2.mutex);
+}
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.h 
b/drivers/media/platform/omap3isp/ispcsiphy.h
index 28b63b28f9f7..978ca5c80a6c 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.h
+++ b/drivers/media/platform/omap3isp/ispcsiphy.h
@@ -39,5 +39,6 @@ struct isp_csiphy {
 int omap3isp_csiphy_acquire(struct isp_csiphy *phy);
 void omap3isp_csiphy_release(struct isp_csiphy *phy);
 int omap3isp_csiphy_init(struct isp_device *isp);
+void omap3isp_csiphy_cleanup(struct isp_device *isp);
 
 #endif /* OMAP3_ISP_CSI_PHY_H */
-- 
2.11.0



[PATCH 2/8] dt: bindings: Add strobe property for CCP2

2017-07-05 Thread Sakari Ailus
Document the CSI1/CCP2 property strobe. It signifies the clock or
strobe mode.

Signed-off-by: Sakari Ailus 
Signed-off-by: Ivaylo Dimitrov 
Signed-off-by: Pavel Machek 
Reviewed-By: Sebastian Reichel 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/media/video-interfaces.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
b/Documentation/devicetree/bindings/media/video-interfaces.txt
index 9aa2722b6920..852041a7480c 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.txt
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -117,7 +117,8 @@ Optional endpoint properties
   should be the combined length of data-lanes and clock-lanes properties.
   If the lane-polarities property is omitted, the value must be interpreted
   as 0 (normal). This property is valid for serial busses only.
-
+- strobe: Whether the clock signal is used as clock (0) or strobe (1). Used
+  with CCP2, for instance.
 
 Example
 ---
-- 
2.11.0



[PATCH 5/8] v4l: Add support for CSI-1 and CCP2 busses

2017-07-05 Thread Sakari Ailus
From: Sakari Ailus 

CCP2 and CSI-1, are older single data lane serial busses.

Signed-off-by: Sakari Ailus 
Signed-off-by: Pavel Machek 
---
 drivers/media/platform/pxa_camera.c  |  3 ++
 drivers/media/platform/soc_camera/soc_mediabus.c |  3 ++
 drivers/media/v4l2-core/v4l2-fwnode.c| 58 +++-
 include/media/v4l2-fwnode.h  | 19 
 include/media/v4l2-mediabus.h|  4 ++
 5 files changed, 76 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index 399095170b6e..17e797c9559f 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -638,6 +638,9 @@ static unsigned int pxa_mbus_config_compatible(const struct 
v4l2_mbus_config *cf
mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK 
|
 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK);
return (!mipi_lanes || !mipi_clock) ? 0 : common_flags;
+   default:
+   __WARN();
+   return -EINVAL;
}
return 0;
 }
diff --git a/drivers/media/platform/soc_camera/soc_mediabus.c 
b/drivers/media/platform/soc_camera/soc_mediabus.c
index 57581f626f4c..43192d80beef 100644
--- a/drivers/media/platform/soc_camera/soc_mediabus.c
+++ b/drivers/media/platform/soc_camera/soc_mediabus.c
@@ -508,6 +508,9 @@ unsigned int soc_mbus_config_compatible(const struct 
v4l2_mbus_config *cfg,
mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK 
|
 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK);
return (!mipi_lanes || !mipi_clock) ? 0 : common_flags;
+   default:
+   __WARN();
+   return -EINVAL;
}
return 0;
 }
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index d71dd3913cd9..76a88f210cb6 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -154,6 +154,31 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
 
 }
 
+void v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode,
+struct v4l2_fwnode_endpoint *vep,
+u32 bus_type)
+{
+   struct v4l2_fwnode_bus_mipi_csi1 *bus = >bus.mipi_csi1;
+   u32 v;
+
+   if (!fwnode_property_read_u32(fwnode, "clock-inv", ))
+   bus->clock_inv = v;
+
+   if (!fwnode_property_read_u32(fwnode, "strobe", ))
+   bus->strobe = v;
+
+   if (!fwnode_property_read_u32(fwnode, "data-lanes", ))
+   bus->data_lane = v;
+
+   if (!fwnode_property_read_u32(fwnode, "clock-lanes", ))
+   bus->clock_lane = v;
+
+   if (bus_type == V4L2_FWNODE_BUS_TYPE_CCP2)
+  vep->bus_type = V4L2_MBUS_CCP2;
+   else
+  vep->bus_type = V4L2_MBUS_CSI1;
+}
+
 /**
  * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties
  * @fwnode: pointer to the endpoint's fwnode handle
@@ -187,17 +212,28 @@ int v4l2_fwnode_endpoint_parse(struct fwnode_handle 
*fwnode,
 
fwnode_property_read_u32(fwnode, "bus-type", _type);
 
-   rval = v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep);
-   if (rval)
-   return rval;
-   /*
-* Parse the parallel video bus properties only if none
-* of the MIPI CSI-2 specific properties were found.
-*/
-   if (vep->bus.mipi_csi2.flags == 0)
-   v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep);
-
-   return 0;
+   switch (bus_type) {
+   case V4L2_FWNODE_BUS_TYPE_GUESS:
+   rval = v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep);
+   if (rval)
+   return rval;
+   /*
+* Parse the parallel video bus properties only if none
+* of the MIPI CSI-2 specific properties were found.
+*/
+   if (vep->bus.mipi_csi2.flags == 0)
+   v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep);
+
+   return 0;
+   case V4L2_FWNODE_BUS_TYPE_CCP2:
+   case V4L2_FWNODE_BUS_TYPE_CSI1:
+   v4l2_fwnode_endpoint_parse_csi1_bus(fwnode, vep, bus_type);
+
+   return 0;
+   default:
+   pr_warn("unsupported bus type %u\n", bus_type);
+   return -EINVAL;
+   }
 }
 EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_parse);
 
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index ecc1233a873e..29ae22af 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -56,6 +56,24 @@ struct v4l2_fwnode_bus_parallel {
 };
 
 /**
+ * struct v4l2_fwnode_bus_mipi_csi1 - CSI-1/CCP2 data bus structure
+ * @clock_inv: polarity of 

[PATCH 4/8] v4l: fwnode: Obtain data bus type from FW

2017-07-05 Thread Sakari Ailus
From: Sakari Ailus 

Just obtain it. It'll actually get used soon with CSI-1/CCP2.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 8df26010d006..d71dd3913cd9 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -28,6 +28,14 @@
 
 #include 
 
+enum v4l2_fwnode_bus_type {
+   V4L2_FWNODE_BUS_TYPE_GUESS = 0,
+   V4L2_FWNODE_BUS_TYPE_CSI2_CPHY,
+   V4L2_FWNODE_BUS_TYPE_CSI1,
+   V4L2_FWNODE_BUS_TYPE_CCP2,
+   NR_OF_V4L2_FWNODE_BUS_TYPE,
+};
+
 static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
   struct v4l2_fwnode_endpoint *vep)
 {
@@ -168,6 +176,7 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
 int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
   struct v4l2_fwnode_endpoint *vep)
 {
+   u32 bus_type = 0;
int rval;
 
fwnode_graph_parse_endpoint(fwnode, >base);
@@ -176,6 +185,8 @@ int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
memset(>bus_type, 0, sizeof(*vep) -
   offsetof(typeof(*vep), bus_type));
 
+   fwnode_property_read_u32(fwnode, "bus-type", _type);
+
rval = v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep);
if (rval)
return rval;
-- 
2.11.0



[PATCH 3/8] v4l: fwnode: Call CSI2 bus csi2, not csi

2017-07-05 Thread Sakari Ailus
The function to parse CSI2 bus parameters was called
v4l2_fwnode_endpoint_parse_csi_bus(), rename it as
v4l2_fwnode_endpoint_parse_csi2_bus() in anticipation of CSI1/CCP2
support.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 153c53ca3925..8df26010d006 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -28,8 +28,8 @@
 
 #include 
 
-static int v4l2_fwnode_endpoint_parse_csi_bus(struct fwnode_handle *fwnode,
- struct v4l2_fwnode_endpoint *vep)
+static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
+  struct v4l2_fwnode_endpoint *vep)
 {
struct v4l2_fwnode_bus_mipi_csi2 *bus = >bus.mipi_csi2;
bool have_clk_lane = false;
@@ -176,7 +176,7 @@ int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
memset(>bus_type, 0, sizeof(*vep) -
   offsetof(typeof(*vep), bus_type));
 
-   rval = v4l2_fwnode_endpoint_parse_csi_bus(fwnode, vep);
+   rval = v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep);
if (rval)
return rval;
/*
-- 
2.11.0



[PATCH 6/8] smiapp: add CCP2 support

2017-07-05 Thread Sakari Ailus
From: Pavel Machek 

Add support for CCP2 connected SMIA sensors as found
on the Nokia N900.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Ivaylo Dimitrov 
Signed-off-by: Pavel Machek 
Signed-off-by: Sakari Ailus 
---
 drivers/media/i2c/smiapp/smiapp-core.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index e0b0c032c4ac..aff55e1dffe7 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2809,13 +2809,19 @@ static struct smiapp_hwconfig 
*smiapp_get_hwconfig(struct device *dev)
switch (bus_cfg->bus_type) {
case V4L2_MBUS_CSI2:
hwcfg->csi_signalling_mode = SMIAPP_CSI_SIGNALLING_MODE_CSI2;
+   hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes;
+   break;
+   case V4L2_MBUS_CCP2:
+   hwcfg->csi_signalling_mode = (bus_cfg->bus.mipi_csi1.strobe) ?
+   SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_STROBE :
+   SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_CLOCK;
+   hwcfg->lanes = 1;
break;
-   /* FIXME: add CCP2 support. */
default:
+   dev_err(dev, "unsupported bus %u\n", bus_cfg->bus_type);
goto out_err;
}
 
-   hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes;
dev_dbg(dev, "lanes %u\n", hwcfg->lanes);
 
/* NVM size is not mandatory */
@@ -2828,8 +2834,8 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct 
device *dev)
goto out_err;
}
 
-   dev_dbg(dev, "nvm %d, clk %d, csi %d\n", hwcfg->nvm_size,
-   hwcfg->ext_clk, hwcfg->csi_signalling_mode);
+   dev_dbg(dev, "nvm %d, clk %d, mode %d\n",
+   hwcfg->nvm_size, hwcfg->ext_clk, hwcfg->csi_signalling_mode);
 
if (!bus_cfg->nr_of_link_frequencies) {
dev_warn(dev, "no link frequencies defined\n");
-- 
2.11.0