cron job: media_tree daily build: OK

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

Results of the daily build of media_tree:

date:   Tue Jul 24 05:00:11 CEST 2018
media-tree git hash:39fbb88165b2bbbc77ea7acab5f10632a31526e6
media_build git hash:   f3b64e45d2f2ef45cd4ae5b90a8f2a4fb284e43c
v4l-utils git hash: 5a99dc69d0bf79bedadd5c9675033a8815fceb0e
edid-decode git hash:   ab18befbcacd6cd4dff63faa82e32700369d6f25
gcc version:i686-linux-gcc (GCC) 8.1.0
sparse version: 0.5.2
smatch version: 0.5.1
host hardware:  x86_64
host os:4.16.0-1-amd64

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-i686: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
Check COMPILE_TEST: OK
linux-2.6.36.4-i686: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-i686: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-i686: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-i686: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.101-i686: OK
linux-3.0.101-x86_64: OK
linux-3.1.10-i686: OK
linux-3.1.10-x86_64: OK
linux-3.2.102-i686: OK
linux-3.2.102-x86_64: OK
linux-3.3.8-i686: OK
linux-3.3.8-x86_64: OK
linux-3.4.113-i686: OK
linux-3.4.113-x86_64: OK
linux-3.5.7-i686: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-i686: OK
linux-3.6.11-x86_64: OK
linux-3.7.10-i686: OK
linux-3.7.10-x86_64: OK
linux-3.8.13-i686: OK
linux-3.8.13-x86_64: OK
linux-3.9.11-i686: OK
linux-3.9.11-x86_64: OK
linux-3.10.108-i686: OK
linux-3.10.108-x86_64: OK
linux-3.11.10-i686: OK
linux-3.11.10-x86_64: OK
linux-3.12.74-i686: OK
linux-3.12.74-x86_64: OK
linux-3.13.11-i686: OK
linux-3.13.11-x86_64: OK
linux-3.14.79-i686: OK
linux-3.14.79-x86_64: OK
linux-3.15.10-i686: OK
linux-3.15.10-x86_64: OK
linux-3.16.57-i686: OK
linux-3.16.57-x86_64: OK
linux-3.17.8-i686: OK
linux-3.17.8-x86_64: OK
linux-3.18.115-i686: OK
linux-3.18.115-x86_64: OK
linux-3.19.8-i686: OK
linux-3.19.8-x86_64: OK
linux-4.0.9-i686: OK
linux-4.0.9-x86_64: OK
linux-4.1.52-i686: OK
linux-4.1.52-x86_64: OK
linux-4.2.8-i686: OK
linux-4.2.8-x86_64: OK
linux-4.3.6-i686: OK
linux-4.3.6-x86_64: OK
linux-4.4.140-i686: OK
linux-4.4.140-x86_64: OK
linux-4.5.7-i686: OK
linux-4.5.7-x86_64: OK
linux-4.6.7-i686: OK
linux-4.6.7-x86_64: OK
linux-4.7.10-i686: OK
linux-4.7.10-x86_64: OK
linux-4.8.17-i686: OK
linux-4.8.17-x86_64: OK
linux-4.9.112-i686: OK
linux-4.9.112-x86_64: OK
linux-4.10.17-i686: OK
linux-4.10.17-x86_64: OK
linux-4.11.12-i686: OK
linux-4.11.12-x86_64: OK
linux-4.12.14-i686: OK
linux-4.12.14-x86_64: OK
linux-4.13.16-i686: OK
linux-4.13.16-x86_64: OK
linux-4.14.55-i686: OK
linux-4.14.55-x86_64: OK
linux-4.15.18-i686: OK
linux-4.15.18-x86_64: OK
linux-4.16.18-i686: OK
linux-4.16.18-x86_64: OK
linux-4.17.6-i686: OK
linux-4.17.6-x86_64: OK
linux-4.18-rc4-i686: OK
linux-4.18-rc4-x86_64: OK
apps: OK
spec-git: OK

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.html


[PATCH RESEND v6 15/17] media: platform: Switch to v4l2_async_notifier_add_subdev

2018-07-23 Thread Steve Longerbeam
Switch all media platform drivers to call v4l2_async_notifier_add_subdev()
to add asd's to a notifier, in place of referencing the notifier->subdevs[]
array. These drivers also must now call v4l2_async_notifier_init() before
adding asd's to their notifiers.

There may still be cases where a platform driver maintains a list of
asd's that is a duplicate of the notifier asd_list, in which case its
possible the platform driver list can be removed, and can reference the
notifier asd_list instead. One example of where a duplicate list has
been removed in this patch is xilinx-vipp.c. If there are such cases
remaining, those drivers should be optimized to remove the duplicate
platform driver asd lists.

None of the changes to the platform drivers in this patch have been
tested. Verify that the async subdevices needed by the platform are
bound at load time, and that the driver unloads and reloads correctly
with no memory leaking of asd objects.

Suggested-by: Sakari Ailus 
Signed-off-by: Steve Longerbeam 
---
Changes since v5:
- remove reference to notifier.num_subdevs, and call
  v4l2_async_notifier_init(). Suggested by Sakari Ailus.
- removed "OF" qualifier when passing fwnode pointers to printk in
  xilinx-vipp.c. Reported by Dan Carpenter.
- fixed double node put in vpif_capture.c. Reported by Sakari.
---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c   |   2 +-
 drivers/media/platform/am437x/am437x-vpfe.c|  82 ++--
 drivers/media/platform/atmel/atmel-isc.c   |  15 ++-
 drivers/media/platform/atmel/atmel-isi.c   |  17 +--
 drivers/media/platform/cadence/cdns-csi2rx.c   |  28 ++--
 drivers/media/platform/davinci/vpif_capture.c  |  71 +-
 drivers/media/platform/davinci/vpif_display.c  |  25 ++--
 drivers/media/platform/exynos4-is/media-dev.c  |  32 +++--
 drivers/media/platform/exynos4-is/media-dev.h  |   1 -
 drivers/media/platform/pxa_camera.c|  25 ++--
 drivers/media/platform/qcom/camss-8x16/camss.c |  86 ++--
 drivers/media/platform/qcom/camss-8x16/camss.h |   2 +-
 drivers/media/platform/rcar-vin/rcar-core.c|   2 +-
 drivers/media/platform/rcar-vin/rcar-csi2.c|  22 ++--
 drivers/media/platform/rcar_drif.c |  18 ++-
 drivers/media/platform/renesas-ceu.c   |  53 
 drivers/media/platform/soc_camera/soc_camera.c |  35 +++--
 drivers/media/platform/stm32/stm32-dcmi.c  |  24 ++--
 drivers/media/platform/ti-vpe/cal.c|  48 +--
 drivers/media/platform/xilinx/xilinx-vipp.c| 173 -
 drivers/media/platform/xilinx/xilinx-vipp.h|   4 -
 21 files changed, 423 insertions(+), 342 deletions(-)

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c 
b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index 4a5f7c3..ca3ad11 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -1508,7 +1508,7 @@ static int cio2_notifier_init(struct cio2_device *cio2)
if (ret < 0)
return ret;
 
-   if (!cio2->notifier.num_subdevs)
+   if (list_empty(>notifier.asd_list))
return -ENODEV; /* no endpoint */
 
cio2->notifier.ops = _async_ops;
diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
b/drivers/media/platform/am437x/am437x-vpfe.c
index b05738a..b19e0ab 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -2423,30 +2423,32 @@ static const struct v4l2_async_notifier_operations 
vpfe_async_ops = {
 };
 
 static struct vpfe_config *
-vpfe_get_pdata(struct platform_device *pdev)
+vpfe_get_pdata(struct vpfe_device *vpfe)
 {
struct device_node *endpoint = NULL;
struct v4l2_fwnode_endpoint bus_cfg;
+   struct device *dev = vpfe->pdev;
struct vpfe_subdev_info *sdinfo;
struct vpfe_config *pdata;
unsigned int flags;
unsigned int i;
int err;
 
-   dev_dbg(>dev, "vpfe_get_pdata\n");
+   dev_dbg(dev, "vpfe_get_pdata\n");
 
-   if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
-   return pdev->dev.platform_data;
+   v4l2_async_notifier_init(>notifier);
 
-   pdata = devm_kzalloc(>dev, sizeof(*pdata), GFP_KERNEL);
+   if (!IS_ENABLED(CONFIG_OF) || !dev->of_node)
+   return dev->platform_data;
+
+   pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return NULL;
 
for (i = 0; ; i++) {
struct device_node *rem;
 
-   endpoint = of_graph_get_next_endpoint(pdev->dev.of_node,
- endpoint);
+   endpoint = of_graph_get_next_endpoint(dev->of_node, endpoint);
if (!endpoint)
break;
 
@@ -2473,16 +2475,16 @@ vpfe_get_pdata(struct platform_device *pdev)
err = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint),
 _cfg);

Re: [PATCH 16/16] media: imx: add mem2mem device

2018-07-23 Thread Steve Longerbeam




On 07/23/2018 12:31 AM, Philipp Zabel wrote:


ipu_image_convert_adjust tries to adjust both input and output image at
the same time, here we just have the format of either input or output
image. Do you suggest to split this function into an input and an output
version?

See b4362162c0 ("media: imx: mem2mem: Use ipu_image_convert_adjust
in try format")

Alright, this looks fine to me. I was worried about inter-format
limitations, but the only one seems to be the output size lower bound to
1/4 of the input size. Should S_FMT(OUT) also update the capture format
if adjustments were made to keep a consistent state?


That's a good question, I don't know if the mem2mem API allows for
that, but if it does we should do that for consistent state as you said.

In b4362162c0, the current capture format is used to adjust output
format during S_FMT(OUT) but any capture format changes are
dropped, and vice-versa.

Steve



[PATCH 01/21] v4l: fwnode: Add debug prints for V4L2 endpoint property parsing

2018-07-23 Thread Sakari Ailus
Print debug info as standard V4L2 endpoint are parsed.

Signed-off-by: Sakari Ailus 
Reviewed-by: Niklas Söderlund 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 108 ++
 1 file changed, 85 insertions(+), 23 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 5a65ca19ba05..dae01d5f570e 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -66,6 +66,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
lanes_used |= BIT(array[i]);
 
bus->data_lanes[i] = array[i];
+   pr_debug("lane %u position %u\n", i, array[i]);
}
 
rval = fwnode_property_read_u32_array(fwnode,
@@ -82,8 +83,13 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
   "lane-polarities", array,
   1 + bus->num_data_lanes);
 
-   for (i = 0; i < 1 + bus->num_data_lanes; i++)
+   for (i = 0; i < 1 + bus->num_data_lanes; i++) {
bus->lane_polarities[i] = array[i];
+   pr_debug("lane %u polarity %sinverted",
+i, array[i] ? "" : "not ");
+   }
+   } else {
+   pr_debug("no lane polarities defined, assuming not 
inverted\n");
}
 
}
@@ -95,12 +101,15 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
 
bus->clock_lane = v;
have_clk_lane = true;
+   pr_debug("clock lane position %u\n", v);
}
 
-   if (fwnode_property_present(fwnode, "clock-noncontinuous"))
+   if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
-   else if (have_clk_lane || bus->num_data_lanes > 0)
+   pr_debug("non-continuous clock\n");
+   } else if (have_clk_lane || bus->num_data_lanes > 0) {
flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+   }
 
bus->flags = flags;
vep->bus_type = V4L2_MBUS_CSI2;
@@ -115,48 +124,69 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
unsigned int flags = 0;
u32 v;
 
-   if (!fwnode_property_read_u32(fwnode, "hsync-active", ))
+   if (!fwnode_property_read_u32(fwnode, "hsync-active", )) {
flags |= v ? V4L2_MBUS_HSYNC_ACTIVE_HIGH :
V4L2_MBUS_HSYNC_ACTIVE_LOW;
+   pr_debug("hsync-active %s\n", v ? "high" : "low");
+   }
 
-   if (!fwnode_property_read_u32(fwnode, "vsync-active", ))
+   if (!fwnode_property_read_u32(fwnode, "vsync-active", )) {
flags |= v ? V4L2_MBUS_VSYNC_ACTIVE_HIGH :
V4L2_MBUS_VSYNC_ACTIVE_LOW;
+   pr_debug("vsync-active %s\n", v ? "high" : "low");
+   }
 
-   if (!fwnode_property_read_u32(fwnode, "field-even-active", ))
+   if (!fwnode_property_read_u32(fwnode, "field-even-active", )) {
flags |= v ? V4L2_MBUS_FIELD_EVEN_HIGH :
V4L2_MBUS_FIELD_EVEN_LOW;
+   pr_debug("field-even-active %s\n", v ? "high" : "low");
+   }
+
if (flags)
vep->bus_type = V4L2_MBUS_PARALLEL;
else
vep->bus_type = V4L2_MBUS_BT656;
 
-   if (!fwnode_property_read_u32(fwnode, "pclk-sample", ))
+   if (!fwnode_property_read_u32(fwnode, "pclk-sample", )) {
flags |= v ? V4L2_MBUS_PCLK_SAMPLE_RISING :
V4L2_MBUS_PCLK_SAMPLE_FALLING;
+   pr_debug("pclk-sample %s\n", v ? "high" : "low");
+   }
 
-   if (!fwnode_property_read_u32(fwnode, "data-active", ))
+   if (!fwnode_property_read_u32(fwnode, "data-active", )) {
flags |= v ? V4L2_MBUS_DATA_ACTIVE_HIGH :
V4L2_MBUS_DATA_ACTIVE_LOW;
+   pr_debug("data-active %s\n", v ? "high" : "low");
+   }
 
-   if (fwnode_property_present(fwnode, "slave-mode"))
+   if (fwnode_property_present(fwnode, "slave-mode")) {
+   pr_debug("slave mode\n");
flags |= V4L2_MBUS_SLAVE;
-   else
+   } else {
flags |= V4L2_MBUS_MASTER;
+   }
 
-   if (!fwnode_property_read_u32(fwnode, "bus-width", ))
+   if (!fwnode_property_read_u32(fwnode, "bus-width", )) {
bus->bus_width = v;
+   pr_debug("bus-width %u\n", v);
+   }
 
-   if (!fwnode_property_read_u32(fwnode, "data-shift", ))
+   if (!fwnode_property_read_u32(fwnode, "data-shift", )) {
bus->data_shift = v;
+   pr_debug("data-shift %u\n", v);
+   }
 
-   if 

[PATCH 14/21] v4l: fwnode: Use default parallel flags

2018-07-23 Thread Sakari Ailus
The caller may provide default flags for the endpoint. Change the
configuration based on what is available through the fwnode property API.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 1e64182b74dd..539f7ca940fd 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -184,31 +184,44 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
bool is_parallel = false;
u32 v;
 
+   if (bus_type == V4L2_MBUS_PARALLEL || bus_type == V4L2_MBUS_BT656)
+   flags = bus->flags;
+
if (!fwnode_property_read_u32(fwnode, "hsync-active", )) {
+   flags &= ~(V4L2_MBUS_HSYNC_ACTIVE_HIGH |
+  V4L2_MBUS_HSYNC_ACTIVE_LOW);
flags |= v ? V4L2_MBUS_HSYNC_ACTIVE_HIGH :
V4L2_MBUS_HSYNC_ACTIVE_LOW;
pr_debug("hsync-active %s\n", v ? "high" : "low");
}
 
if (!fwnode_property_read_u32(fwnode, "vsync-active", )) {
+   flags &= ~(V4L2_MBUS_VSYNC_ACTIVE_HIGH |
+  V4L2_MBUS_VSYNC_ACTIVE_LOW);
flags |= v ? V4L2_MBUS_VSYNC_ACTIVE_HIGH :
V4L2_MBUS_VSYNC_ACTIVE_LOW;
pr_debug("vsync-active %s\n", v ? "high" : "low");
}
 
if (!fwnode_property_read_u32(fwnode, "field-even-active", )) {
+   flags &= ~(V4L2_MBUS_FIELD_EVEN_HIGH |
+  V4L2_MBUS_FIELD_EVEN_LOW);
flags |= v ? V4L2_MBUS_FIELD_EVEN_HIGH :
V4L2_MBUS_FIELD_EVEN_LOW;
pr_debug("field-even-active %s\n", v ? "high" : "low");
}
 
if (!fwnode_property_read_u32(fwnode, "pclk-sample", )) {
+   flags &= ~(V4L2_MBUS_PCLK_SAMPLE_RISING |
+  V4L2_MBUS_PCLK_SAMPLE_FALLING);
flags |= v ? V4L2_MBUS_PCLK_SAMPLE_RISING :
V4L2_MBUS_PCLK_SAMPLE_FALLING;
pr_debug("pclk-sample %s\n", v ? "high" : "low");
}
 
if (!fwnode_property_read_u32(fwnode, "data-active", )) {
+   flags &= ~(V4L2_MBUS_PCLK_SAMPLE_RISING |
+  V4L2_MBUS_PCLK_SAMPLE_FALLING);
flags |= v ? V4L2_MBUS_DATA_ACTIVE_HIGH :
V4L2_MBUS_DATA_ACTIVE_LOW;
pr_debug("data-active %s\n", v ? "high" : "low");
@@ -216,8 +229,10 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
 
if (fwnode_property_present(fwnode, "slave-mode")) {
pr_debug("slave mode\n");
+   flags &= ~V4L2_MBUS_MASTER;
flags |= V4L2_MBUS_SLAVE;
} else {
+   flags &= ~V4L2_MBUS_SLAVE;
flags |= V4L2_MBUS_MASTER;
}
 
@@ -234,12 +249,16 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
}
 
if (!fwnode_property_read_u32(fwnode, "sync-on-green-active", )) {
+   flags &= ~(V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH |
+  V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW);
flags |= v ? V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH :
V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW;
pr_debug("sync-on-green-active %s\n", v ? "high" : "low");
}
 
if (!fwnode_property_read_u32(fwnode, "data-enable-active", )) {
+   flags &= ~(V4L2_MBUS_DATA_ENABLE_HIGH |
+  V4L2_MBUS_DATA_ENABLE_LOW);
flags |= v ? V4L2_MBUS_DATA_ENABLE_HIGH :
V4L2_MBUS_DATA_ENABLE_LOW;
pr_debug("data-enable-active %s\n", v ? "high" : "low");
-- 
2.11.0



[PATCH 02/21] v4l: fwnode: Use fwnode_graph_for_each_endpoint

2018-07-23 Thread Sakari Ailus
Use fwnode_graph_for_each_endpoint iterator for better readability.

Signed-off-by: Sakari Ailus 
Reviewed-by: Niklas Söderlund 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index dae01d5f570e..da13348b1f4a 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -456,8 +456,7 @@ static int __v4l2_async_notifier_parse_fwnode_endpoints(
if (WARN_ON(asd_struct_size < sizeof(struct v4l2_async_subdev)))
return -EINVAL;
 
-   for (fwnode = NULL; (fwnode = fwnode_graph_get_next_endpoint(
-dev_fwnode(dev), fwnode)); ) {
+   fwnode_graph_for_each_endpoint(dev_fwnode(dev), fwnode) {
struct fwnode_handle *dev_fwnode;
bool is_available;
 
-- 
2.11.0



[PATCH 00/21] V4L2 fwnode rework; support for default configuration

2018-07-23 Thread Sakari Ailus
Hello everyone,

I've long thought the V4L2 fwnode framework requires some work (it's buggy
and it does not adequately serve common needs). This set should address in
particular these matters:

- Most devices support a particular media bus type but the V4L2 fwnode
  framework was not able to use such information, but instead tried to
  guess the bus type with varying levels of success while drivers
  generally ignored the results. This patchset makes that possible ---
  setting a bus type enables parsing configuration for only that bus.
  Failing that check results in returning -ENXIO to be returned.

- Support specifying default configuration. If the endpoint has no
  configuration, the defaults set by the driver (as documented in DT
  bindings) will prevail. Any available configuration will still be read
  from the endpoint as one could expect. A common use case for this is
  e.g. the number of CSI-2 lanes. Few devices support lane mapping, and
  default 1:1 mapping is provided in absence of a valid default or
  configuration read OF.

- Debugging information is greatly improved.

- Recognition of the differences between CSI-2 D-PHY and C-PHY. All
  currently supported hardware (or at least drivers) is D-PHY only, so
  this change is still easy.

The smiapp driver is converted to use the new functionality. This patchset
does not address remaining issues such as supporting setting defaults for
e.g. bridge drivers with multiple ports, but with Steve Longerbeam's
patchset we're much closer with that goal. I've rebased this set on top of
Steve's. Albeit the two deal with the same files, there were only a few
trivial conflicts.

Note that I've only tested parsing endpoints for the CSI-2 bus (no
parallel IF hardware). Testing in general would be beneficial: the code
flows are rather convoluted and different hardware tends to excercise
different flows while the use of the use of defaults has a similar
effect.

Comments are welcome.

I've pushed the patches (including Steve's) here:

https://git.linuxtv.org/sailus/media_tree.git/log/?h=v4l2-fwnode>

Sakari Ailus (21):
  v4l: fwnode: Add debug prints for V4L2 endpoint property parsing
  v4l: fwnode: Use fwnode_graph_for_each_endpoint
  v4l: fwnode: Detect bus type correctly
  v4l: fwnode: The CSI-2 clock is continuous if it's not non-continuous
  dt-bindings: media: Specify bus type for MIPI D-PHY, others,
explicitly
  v4l: fwnode: Add definitions for CSI-2 D-PHY, parallel and Bt.656
busses
  v4l: mediabus: Recognise CSI-2 D-PHY and C-PHY
  v4l: fwnode: Make use of newly specified bus types
  v4l: fwnode: Read lane inversion information despite lane numbering
  v4l: fwnode: Only assign configuration if there is no error
  v4l: fwnode: Support driver-defined lane mapping defaults
  v4l: fwnode: Support default CSI-2 lane mapping for drivers
  v4l: fwnode: Parse the graph endpoint as last
  v4l: fwnode: Use default parallel flags
  v4l: fwnode: Allow setting default parameters
  v4l: fwnode: Use media bus type for bus parser selection
  v4l: fwnode: Print bus type
  v4l: fwnode: Use V4L2 fwnode endpoint media bus type if set
  v4l: fwnode: Support parsing of CSI-2 C-PHY endpoints
  v4l: fwnode: Update V4L2 fwnode endpoint parsing documentation
  smiapp: Query the V4L2 endpoint for a specific bus type

 .../devicetree/bindings/media/video-interfaces.txt |   4 +-
 drivers/gpu/ipu-v3/ipu-csi.c   |   2 +-
 drivers/media/i2c/adv7180.c|   2 +-
 drivers/media/i2c/ov2659.c |  14 +-
 drivers/media/i2c/ov5640.c |   4 +-
 drivers/media/i2c/ov5645.c |   2 +-
 drivers/media/i2c/ov7251.c |   4 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c   |   2 +-
 drivers/media/i2c/s5k5baf.c|   4 +-
 drivers/media/i2c/s5k6aa.c |   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  34 +-
 drivers/media/i2c/soc_camera/ov5642.c  |   2 +-
 drivers/media/i2c/tc358743.c   |  28 +-
 drivers/media/pci/intel/ipu3/ipu3-cio2.c   |   2 +-
 drivers/media/platform/cadence/cdns-csi2rx.c   |   2 +-
 drivers/media/platform/cadence/cdns-csi2tx.c   |   2 +-
 drivers/media/platform/marvell-ccic/mcam-core.c|   4 +-
 drivers/media/platform/marvell-ccic/mmp-driver.c   |   2 +-
 drivers/media/platform/omap3isp/isp.c  |   2 +-
 drivers/media/platform/pxa_camera.c|   2 +-
 drivers/media/platform/rcar-vin/rcar-csi2.c|   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |   2 +-
 drivers/media/platform/stm32/stm32-dcmi.c  |   2 +-
 drivers/media/platform/ti-vpe/cal.c|   2 +-
 drivers/media/v4l2-core/v4l2-fwnode.c  | 510 -
 drivers/staging/media/imx/imx-media-csi.c  |   2 +-
 drivers/staging/media/imx/imx6-mipi-csi2.c |   2 +-
 

[PATCH 11/21] v4l: fwnode: Support driver-defined lane mapping defaults

2018-07-23 Thread Sakari Ailus
Make use of the default CSI-2 lane mapping from caller-passed
configuration.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 7c6513625f13..ed147b6fd315 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -55,10 +55,14 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
u32 v;
int rval;
 
-   if (bus_type == V4L2_FWNODE_BUS_TYPE_CSI2_DPHY)
+   if (bus_type == V4L2_FWNODE_BUS_TYPE_CSI2_DPHY) {
num_data_lanes = min_t(u32, bus->num_data_lanes,
   V4L2_FWNODE_CSI2_MAX_DATA_LANES);
 
+   for (i = 0; i < num_data_lanes; i++)
+   array[i] = bus->data_lanes[i];
+   }
+
rval = fwnode_property_read_u32_array(fwnode, "data-lanes", NULL, 0);
if (rval > 0) {
num_data_lanes =
@@ -66,15 +70,15 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
 
fwnode_property_read_u32_array(fwnode, "data-lanes", array,
   num_data_lanes);
+   }
 
-   for (i = 0; i < num_data_lanes; i++) {
-   if (lanes_used & BIT(array[i]))
-   pr_warn("duplicated lane %u in data-lanes\n",
-   array[i]);
-   lanes_used |= BIT(array[i]);
+   for (i = 0; i < num_data_lanes; i++) {
+   if (lanes_used & BIT(array[i]))
+   pr_warn("duplicated lane %u in data-lanes\n",
+   array[i]);
+   lanes_used |= BIT(array[i]);
 
-   pr_debug("lane %u position %u\n", i, array[i]);
-   }
+   pr_debug("lane %u position %u\n", i, array[i]);
}
 
rval = fwnode_property_read_u32_array(fwnode, "lane-polarities", NULL,
-- 
2.11.0



[PATCH 05/21] dt-bindings: media: Specify bus type for MIPI D-PHY, others, explicitly

2018-07-23 Thread Sakari Ailus
Allow specifying the bus type explicitly for MIPI D-PHY, parallel and
Bt.656 busses. This is useful for devices that can make use of different
bus types. There are CSI-2 transmitters and receivers but the PHY
selection needs to be made between C-PHY and D-PHY; many devices also
support parallel and Bt.656 interfaces but the means to pass that
information to software wasn't there.

Autodetection (value 0) is removed as an option as the property could be
simply omitted in that case.

Signed-off-by: Sakari Ailus 
---
 Documentation/devicetree/bindings/media/video-interfaces.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
b/Documentation/devicetree/bindings/media/video-interfaces.txt
index baf9d9756b3c..f884ada0bffc 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.txt
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -100,10 +100,12 @@ Optional endpoint properties
   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
+  4 - MIPI CSI-2 D-PHY
+  5 - Parallel
+  6 - Bt.656
 - 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 03/21] v4l: fwnode: Detect bus type correctly

2018-07-23 Thread Sakari Ailus
In case the device supports multiple video bus types on an endpoint, the
V4L2 fwnode framework attempts to detect the type based on the available
information. This wasn't working really well, and sometimes could lead to
the V4L2 fwnode endpoint struct as being mishandled between the bus types.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 43 +++
 include/media/v4l2-mediabus.h |  2 ++
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index da13348b1f4a..55214ff5a616 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -111,8 +111,10 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
}
 
-   bus->flags = flags;
-   vep->bus_type = V4L2_MBUS_CSI2;
+   if (lanes_used || have_clk_lane || flags) {
+   bus->flags = flags;
+   vep->bus_type = V4L2_MBUS_CSI2;
+   }
 
return 0;
 }
@@ -122,6 +124,7 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
 {
struct v4l2_fwnode_bus_parallel *bus = >bus.parallel;
unsigned int flags = 0;
+   bool is_parallel = false;
u32 v;
 
if (!fwnode_property_read_u32(fwnode, "hsync-active", )) {
@@ -142,11 +145,6 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
pr_debug("field-even-active %s\n", v ? "high" : "low");
}
 
-   if (flags)
-   vep->bus_type = V4L2_MBUS_PARALLEL;
-   else
-   vep->bus_type = V4L2_MBUS_BT656;
-
if (!fwnode_property_read_u32(fwnode, "pclk-sample", )) {
flags |= v ? V4L2_MBUS_PCLK_SAMPLE_RISING :
V4L2_MBUS_PCLK_SAMPLE_FALLING;
@@ -168,11 +166,13 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
 
if (!fwnode_property_read_u32(fwnode, "bus-width", )) {
bus->bus_width = v;
+   is_parallel = true;
pr_debug("bus-width %u\n", v);
}
 
if (!fwnode_property_read_u32(fwnode, "data-shift", )) {
bus->data_shift = v;
+   is_parallel = true;
pr_debug("data-shift %u\n", v);
}
 
@@ -188,14 +188,24 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
pr_debug("data-enable-active %s\n", v ? "high" : "low");
}
 
-   bus->flags = flags;
-
+   if (flags || is_parallel) {
+   bus->flags = flags;
+   if (flags & (V4L2_MBUS_HSYNC_ACTIVE_HIGH |
+V4L2_MBUS_HSYNC_ACTIVE_LOW |
+V4L2_MBUS_VSYNC_ACTIVE_HIGH |
+V4L2_MBUS_VSYNC_ACTIVE_LOW |
+V4L2_MBUS_FIELD_EVEN_HIGH |
+V4L2_MBUS_FIELD_EVEN_LOW))
+   vep->bus_type = V4L2_MBUS_PARALLEL;
+   else
+   vep->bus_type = V4L2_MBUS_BT656;
+   }
 }
 
 static void
 v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode,
struct v4l2_fwnode_endpoint *vep,
-   u32 bus_type)
+   enum v4l2_fwnode_bus_type bus_type)
 {
struct v4l2_fwnode_bus_mipi_csi1 *bus = >bus.mipi_csi1;
u32 v;
@@ -247,25 +257,20 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
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)
+
+   if (vep->bus_type == V4L2_MBUS_UNKNOWN)
v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep);
 
-   break;
+   return vep->bus_type == V4L2_MBUS_UNKNOWN ? -EINVAL : 0;
case V4L2_FWNODE_BUS_TYPE_CCP2:
case V4L2_FWNODE_BUS_TYPE_CSI1:
v4l2_fwnode_endpoint_parse_csi1_bus(fwnode, vep, bus_type);
 
-   break;
+   return 0;
default:
pr_warn("unsupported bus type %u\n", bus_type);
return -EINVAL;
}
-
-   return 0;
 }
 
 int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 4bbb5f3d2b02..66d74c813f53 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -70,6 +70,7 @@
 
 /**
  * enum v4l2_mbus_type - media bus type
+ * @V4L2_MBUS_UNKNOWN: unknown bus type, no V4L2 mediabus configuration
  * @V4L2_MBUS_PARALLEL:parallel interface with hsync and vsync
  * 

[PATCH 21/21] smiapp: Query the V4L2 endpoint for a specific bus type

2018-07-23 Thread Sakari Ailus
Instead of opportunistically trying to gather some information from the
V4L2 endpoint, set the bus type and let the V4L2 fwnode framework figure
out the configuration.

Signed-off-by: Sakari Ailus 
---
 drivers/media/i2c/smiapp/smiapp-core.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 048ab6cfaa97..0d660349b13c 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2775,7 +2775,13 @@ static struct smiapp_hwconfig 
*smiapp_get_hwconfig(struct device *dev)
if (!ep)
return NULL;
 
+   bus_cfg.bus_type = V4L2_MBUS_CSI2_DPHY;
rval = v4l2_fwnode_endpoint_alloc_parse(ep, _cfg);
+   if (rval == -ENXIO) {
+   bus_cfg = (struct v4l2_fwnode_endpoint)
+   { .bus_type = V4L2_MBUS_CCP2 };
+   rval = v4l2_fwnode_endpoint_alloc_parse(ep, _cfg);
+   }
if (rval)
goto out_err;
 
-- 
2.11.0



[PATCH 06/21] v4l: fwnode: Add definitions for CSI-2 D-PHY, parallel and Bt.656 busses

2018-07-23 Thread Sakari Ailus
Add definitions corresponding to DT bindings to the CSI-2 D-PHY, parallel
and Bt.656 busses.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 291b3dcc19f3..4c98d17ab124 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -36,6 +36,9 @@ enum v4l2_fwnode_bus_type {
V4L2_FWNODE_BUS_TYPE_CSI2_CPHY,
V4L2_FWNODE_BUS_TYPE_CSI1,
V4L2_FWNODE_BUS_TYPE_CCP2,
+   V4L2_FWNODE_BUS_TYPE_CSI2_DPHY,
+   V4L2_FWNODE_BUS_TYPE_PARALLEL,
+   V4L2_FWNODE_BUS_TYPE_BT656,
NR_OF_V4L2_FWNODE_BUS_TYPE,
 };
 
-- 
2.11.0



[PATCH 04/21] v4l: fwnode: The CSI-2 clock is continuous if it's not non-continuous

2018-07-23 Thread Sakari Ailus
The continuous clock flag was only set if there was a clock or data lanes.
This isn't needed as such a configuration is invalid to begin with. Always
set the continuous clock flag if the non-continuous property is not found.

Still don't consider the continuous clock flag as an indication that this
is CSI-2 as it's set in the absence of the property.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 55214ff5a616..291b3dcc19f3 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -107,11 +107,12 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
pr_debug("non-continuous clock\n");
-   } else if (have_clk_lane || bus->num_data_lanes > 0) {
+   } else {
flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
}
 
-   if (lanes_used || have_clk_lane || flags) {
+   if (lanes_used || have_clk_lane ||
+   (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
bus->flags = flags;
vep->bus_type = V4L2_MBUS_CSI2;
}
-- 
2.11.0



[PATCH 18/21] v4l: fwnode: Use V4L2 fwnode endpoint media bus type if set

2018-07-23 Thread Sakari Ailus
Use the given media bus type set by the caller. If none is given (i.e. the
mbus type is V4L2_MBUS_UNKNOWN, or 0), fall back to the old behaviour.
This is to obtain the information from the DT or try to guess the bus
type.

-ENXIO is returned if the caller sets the bus type but that does not match
with what's in DT.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 8914abd20ee8..56e3b6395171 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -409,7 +409,7 @@ v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle 
*fwnode,
 static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
struct v4l2_fwnode_endpoint *vep)
 {
-   u32 bus_type = 0;
+   u32 bus_type = V4L2_FWNODE_BUS_TYPE_GUESS;
enum v4l2_mbus_type mbus_type;
int rval;
 
@@ -432,13 +432,24 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
 v4l2_fwnode_bus_type_to_string(bus_type), bus_type,
 v4l2_fwnode_mbus_type_to_string(vep->bus_type),
 vep->bus_type);
-
mbus_type = v4l2_fwnode_bus_type_to_mbus(bus_type);
 
-   switch (mbus_type) {
+   if (vep->bus_type != V4L2_MBUS_UNKNOWN) {
+   if (mbus_type != V4L2_MBUS_UNKNOWN &&
+   vep->bus_type != mbus_type) {
+   pr_debug("expecting bus type %s\n",
+v4l2_fwnode_mbus_type_to_string(
+vep->bus_type));
+   return -ENXIO;
+   }
+   } else {
+   vep->bus_type = mbus_type;
+   }
+
+   switch (vep->bus_type) {
case V4L2_MBUS_UNKNOWN:
rval = v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep,
-  mbus_type);
+  V4L2_MBUS_UNKNOWN);
if (rval)
return rval;
 
@@ -457,20 +468,19 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
 
case V4L2_MBUS_CCP2:
case V4L2_MBUS_CSI1:
-   v4l2_fwnode_endpoint_parse_csi1_bus(fwnode, vep, mbus_type);
+   v4l2_fwnode_endpoint_parse_csi1_bus(fwnode, vep, vep->bus_type);
break;
 
case V4L2_MBUS_CSI2_DPHY:
-   vep->bus_type = V4L2_MBUS_CSI2_DPHY;
rval = v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep,
-  mbus_type);
+  vep->bus_type);
if (rval)
return rval;
 
break;
case V4L2_MBUS_PARALLEL:
case V4L2_MBUS_BT656:
-   v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep, mbus_type);
+   v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep, 
vep->bus_type);
 
break;
default:
-- 
2.11.0



[PATCH 09/21] v4l: fwnode: Read lane inversion information despite lane numbering

2018-07-23 Thread Sakari Ailus
Read the lane inversion independently of whether the "data-lanes" property
exists. This makes sense since the caller may pass the number of lanes as
the default configuration while the lane inversion configuration may still
be available in firmware.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index e62a1fcabd8f..3f30904c158c 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -43,26 +43,31 @@ enum v4l2_fwnode_bus_type {
 };
 
 static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
-  struct v4l2_fwnode_endpoint *vep)
+  struct v4l2_fwnode_endpoint *vep,
+  enum v4l2_fwnode_bus_type 
bus_type)
 {
struct v4l2_fwnode_bus_mipi_csi2 *bus = >bus.mipi_csi2;
bool have_clk_lane = false;
unsigned int flags = 0, lanes_used = 0;
+   u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
+   unsigned int num_data_lanes = 0;
unsigned int i;
u32 v;
int rval;
 
+   if (bus_type == V4L2_FWNODE_BUS_TYPE_CSI2_DPHY)
+   num_data_lanes = min_t(u32, bus->num_data_lanes,
+  V4L2_FWNODE_CSI2_MAX_DATA_LANES);
+
rval = fwnode_property_read_u32_array(fwnode, "data-lanes", NULL, 0);
if (rval > 0) {
-   u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
-
-   bus->num_data_lanes =
+   num_data_lanes =
min_t(int, V4L2_FWNODE_CSI2_MAX_DATA_LANES, rval);
 
fwnode_property_read_u32_array(fwnode, "data-lanes", array,
-  bus->num_data_lanes);
+  num_data_lanes);
 
-   for (i = 0; i < bus->num_data_lanes; i++) {
+   for (i = 0; i < num_data_lanes; i++) {
if (lanes_used & BIT(array[i]))
pr_warn("duplicated lane %u in data-lanes\n",
array[i]);
@@ -71,30 +76,27 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
bus->data_lanes[i] = array[i];
pr_debug("lane %u position %u\n", i, array[i]);
}
+   }
 
-   rval = fwnode_property_read_u32_array(fwnode,
- "lane-polarities", NULL,
- 0);
-   if (rval > 0) {
-   if (rval != 1 + bus->num_data_lanes /* clock+data */) {
-   pr_warn("invalid number of lane-polarities 
entries (need %u, got %u)\n",
-   1 + bus->num_data_lanes, rval);
-   return -EINVAL;
-   }
+   rval = fwnode_property_read_u32_array(fwnode, "lane-polarities", NULL,
+ 0);
+   if (rval > 0) {
+   if (rval != 1 + num_data_lanes /* clock+data */) {
+   pr_warn("invalid number of lane-polarities entries 
(need %u, got %u)\n",
+   1 + num_data_lanes, rval);
+   return -EINVAL;
+   }
 
-   fwnode_property_read_u32_array(fwnode,
-  "lane-polarities", array,
-  1 + bus->num_data_lanes);
+   fwnode_property_read_u32_array(fwnode, "lane-polarities", array,
+  1 + num_data_lanes);
 
-   for (i = 0; i < 1 + bus->num_data_lanes; i++) {
-   bus->lane_polarities[i] = array[i];
-   pr_debug("lane %u polarity %sinverted",
-i, array[i] ? "" : "not ");
-   }
-   } else {
-   pr_debug("no lane polarities defined, assuming not 
inverted\n");
+   for (i = 0; i < 1 + num_data_lanes; i++) {
+   bus->lane_polarities[i] = array[i];
+   pr_debug("lane %u polarity %sinverted",
+i, array[i] ? "" : "not ");
}
-
+   } else {
+   pr_debug("no lane polarities defined, assuming not inverted\n");
}
 
if (!fwnode_property_read_u32(fwnode, "clock-lanes", )) {
@@ -114,10 +116,11 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;

[PATCH 10/21] v4l: fwnode: Only assign configuration if there is no error

2018-07-23 Thread Sakari Ailus
Only assign endpoint configuration if the endpoint is parsed successfully.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 3f30904c158c..7c6513625f13 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -47,7 +47,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
   enum v4l2_fwnode_bus_type 
bus_type)
 {
struct v4l2_fwnode_bus_mipi_csi2 *bus = >bus.mipi_csi2;
-   bool have_clk_lane = false;
+   bool have_clk_lane = false, have_lane_polarities = false;
unsigned int flags = 0, lanes_used = 0;
u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
unsigned int num_data_lanes = 0;
@@ -73,7 +73,6 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
array[i]);
lanes_used |= BIT(array[i]);
 
-   bus->data_lanes[i] = array[i];
pr_debug("lane %u position %u\n", i, array[i]);
}
}
@@ -87,16 +86,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
return -EINVAL;
}
 
-   fwnode_property_read_u32_array(fwnode, "lane-polarities", array,
-  1 + num_data_lanes);
-
-   for (i = 0; i < 1 + num_data_lanes; i++) {
-   bus->lane_polarities[i] = array[i];
-   pr_debug("lane %u polarity %sinverted",
-i, array[i] ? "" : "not ");
-   }
-   } else {
-   pr_debug("no lane polarities defined, assuming not inverted\n");
+   have_lane_polarities = true;
}
 
if (!fwnode_property_read_u32(fwnode, "clock-lanes", )) {
@@ -121,6 +111,22 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
bus->flags = flags;
vep->bus_type = V4L2_MBUS_CSI2_DPHY;
bus->num_data_lanes = num_data_lanes;
+   for (i = 0; i < num_data_lanes; i++)
+   bus->data_lanes[i] = array[i];
+
+   if (have_lane_polarities) {
+   fwnode_property_read_u32_array(fwnode,
+  "lane-polarities", array,
+  1 + num_data_lanes);
+
+   for (i = 0; i < 1 + num_data_lanes; i++) {
+   bus->lane_polarities[i] = array[i];
+   pr_debug("lane %u polarity %sinverted",
+i, array[i] ? "" : "not ");
+   }
+   } else {
+   pr_debug("no lane polarities defined, assuming not 
inverted\n");
+   }
}
 
return 0;
-- 
2.11.0



[PATCH 15/21] v4l: fwnode: Allow setting default parameters

2018-07-23 Thread Sakari Ailus
Instead of allocating the V4L2 fwnode endpoint in
v4l2_fwnode_endpoint_alloc_parse, let the caller to do this. This allows
setting default parameters for the endpoint which is a very common need
for drivers.

Signed-off-by: Sakari Ailus 
---
 drivers/media/i2c/ov2659.c | 14 
 drivers/media/i2c/smiapp/smiapp-core.c | 26 +++
 drivers/media/i2c/tc358743.c   | 26 ---
 drivers/media/v4l2-core/v4l2-fwnode.c  | 59 ++
 include/media/v4l2-fwnode.h|  7 ++--
 5 files changed, 65 insertions(+), 67 deletions(-)

diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 4715edc8ca33..799acce803fe 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1347,8 +1347,9 @@ static struct ov2659_platform_data *
 ov2659_get_pdata(struct i2c_client *client)
 {
struct ov2659_platform_data *pdata;
-   struct v4l2_fwnode_endpoint *bus_cfg;
+   struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
struct device_node *endpoint;
+   int ret;
 
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
@@ -1357,8 +1358,9 @@ ov2659_get_pdata(struct i2c_client *client)
if (!endpoint)
return NULL;
 
-   bus_cfg = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(endpoint));
-   if (IS_ERR(bus_cfg)) {
+   ret = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(endpoint),
+  _cfg);
+   if (ret) {
pdata = NULL;
goto done;
}
@@ -1367,17 +1369,17 @@ ov2659_get_pdata(struct i2c_client *client)
if (!pdata)
goto done;
 
-   if (!bus_cfg->nr_of_link_frequencies) {
+   if (!bus_cfg.nr_of_link_frequencies) {
dev_err(>dev,
"link-frequencies property not found or too many\n");
pdata = NULL;
goto done;
}
 
-   pdata->link_frequency = bus_cfg->link_frequencies[0];
+   pdata->link_frequency = bus_cfg.link_frequencies[0];
 
 done:
-   v4l2_fwnode_endpoint_free(bus_cfg);
+   v4l2_fwnode_endpoint_free(_cfg);
of_node_put(endpoint);
return pdata;
 }
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 9e33c2008ba6..048ab6cfaa97 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2761,7 +2761,7 @@ static int __maybe_unused smiapp_resume(struct device 
*dev)
 static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
 {
struct smiapp_hwconfig *hwcfg;
-   struct v4l2_fwnode_endpoint *bus_cfg;
+   struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
struct fwnode_handle *ep;
struct fwnode_handle *fwnode = dev_fwnode(dev);
u32 rotation;
@@ -2775,27 +2775,27 @@ static struct smiapp_hwconfig 
*smiapp_get_hwconfig(struct device *dev)
if (!ep)
return NULL;
 
-   bus_cfg = v4l2_fwnode_endpoint_alloc_parse(ep);
-   if (IS_ERR(bus_cfg))
+   rval = v4l2_fwnode_endpoint_alloc_parse(ep, _cfg);
+   if (rval)
goto out_err;
 
hwcfg = devm_kzalloc(dev, sizeof(*hwcfg), GFP_KERNEL);
if (!hwcfg)
goto out_err;
 
-   switch (bus_cfg->bus_type) {
+   switch (bus_cfg.bus_type) {
case V4L2_MBUS_CSI2_DPHY:
hwcfg->csi_signalling_mode = SMIAPP_CSI_SIGNALLING_MODE_CSI2;
-   hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes;
+   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) ?
+   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;
default:
-   dev_err(dev, "unsupported bus %u\n", bus_cfg->bus_type);
+   dev_err(dev, "unsupported bus %u\n", bus_cfg.bus_type);
goto out_err;
}
 
@@ -2827,28 +2827,28 @@ static struct smiapp_hwconfig 
*smiapp_get_hwconfig(struct device *dev)
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) {
+   if (!bus_cfg.nr_of_link_frequencies) {
dev_warn(dev, "no link frequencies defined\n");
goto out_err;
}
 
hwcfg->op_sys_clock = devm_kcalloc(
-   dev, bus_cfg->nr_of_link_frequencies + 1 /* guardian */,
+   dev, bus_cfg.nr_of_link_frequencies + 1 /* guardian */,
sizeof(*hwcfg->op_sys_clock), 

[PATCH 16/21] v4l: fwnode: Use media bus type for bus parser selection

2018-07-23 Thread Sakari Ailus
Use the media bus types instead of the fwnode bus types internally. This
is the interface to the drivers as well, making the use of the fwnode bus
types more localised to the V4L2 fwnode framework.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index d9d4e84c45be..0a9d85b3892f 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -42,9 +42,66 @@ enum v4l2_fwnode_bus_type {
NR_OF_V4L2_FWNODE_BUS_TYPE,
 };
 
+static const struct v4l2_fwnode_bus_conv {
+   enum v4l2_fwnode_bus_type fwnode_bus_type;
+   enum v4l2_mbus_type mbus_type;
+   const char *name;
+} busses[] = {
+   {
+   V4L2_FWNODE_BUS_TYPE_GUESS,
+   V4L2_MBUS_UNKNOWN,
+   "not specified",
+   }, {
+   V4L2_FWNODE_BUS_TYPE_CSI2_CPHY,
+   V4L2_MBUS_CSI2_CPHY,
+   "MIPI CSI-2 C-PHY",
+   }, {
+   V4L2_FWNODE_BUS_TYPE_CSI1,
+   V4L2_MBUS_CSI1,
+   "MIPI CSI-1",
+   }, {
+   V4L2_FWNODE_BUS_TYPE_CCP2,
+   V4L2_MBUS_CCP2,
+   "compact camera port 2",
+   }, {
+   V4L2_FWNODE_BUS_TYPE_CSI2_DPHY,
+   V4L2_MBUS_CSI2_DPHY,
+   "MIPI CSI-2 D-PHY",
+   }, {
+   V4L2_FWNODE_BUS_TYPE_PARALLEL,
+   V4L2_MBUS_PARALLEL,
+   "parallel",
+   }, {
+   V4L2_FWNODE_BUS_TYPE_BT656,
+   V4L2_MBUS_BT656,
+   "Bt.656",
+   }
+};
+
+static const struct v4l2_fwnode_bus_conv *
+get_v4l2_fwnode_bus_conv_by_fwnode_bus(enum v4l2_fwnode_bus_type type)
+{
+   unsigned int i;
+
+   for (i = 0; i < ARRAY_SIZE(busses); i++)
+   if (busses[i].fwnode_bus_type == type)
+   return [i];
+
+   return NULL;
+}
+
+static enum v4l2_mbus_type
+v4l2_fwnode_bus_type_to_mbus(enum v4l2_fwnode_bus_type type)
+{
+   const struct v4l2_fwnode_bus_conv *conv =
+   get_v4l2_fwnode_bus_conv_by_fwnode_bus(type);
+
+   return conv ? conv->mbus_type : V4L2_MBUS_UNKNOWN;
+}
+
 static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
   struct v4l2_fwnode_endpoint *vep,
-  enum v4l2_fwnode_bus_type 
bus_type)
+  enum v4l2_mbus_type bus_type)
 {
struct v4l2_fwnode_bus_mipi_csi2 *bus = >bus.mipi_csi2;
bool have_clk_lane = false, have_data_lanes = false,
@@ -58,7 +115,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
u32 v;
int rval;
 
-   if (bus_type == V4L2_FWNODE_BUS_TYPE_CSI2_DPHY) {
+   if (bus_type == V4L2_MBUS_CSI2_DPHY) {
use_default_lane_mapping = true;
 
num_data_lanes = min_t(u32, bus->num_data_lanes,
@@ -134,7 +191,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
}
 
-   if (bus_type == V4L2_FWNODE_BUS_TYPE_CSI2_DPHY || lanes_used ||
+   if (bus_type == V4L2_MBUS_CSI2_DPHY || lanes_used ||
have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
bus->flags = flags;
vep->bus_type = V4L2_MBUS_CSI2_DPHY;
@@ -177,7 +234,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
 
 static void v4l2_fwnode_endpoint_parse_parallel_bus(
struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep,
-   enum v4l2_fwnode_bus_type bus_type)
+   enum v4l2_mbus_type bus_type)
 {
struct v4l2_fwnode_bus_parallel *bus = >bus.parallel;
unsigned int flags = 0;
@@ -274,11 +331,11 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
vep->bus_type = V4L2_MBUS_BT656;
}
break;
-   case V4L2_FWNODE_BUS_TYPE_PARALLEL:
+   case V4L2_MBUS_PARALLEL:
vep->bus_type = V4L2_MBUS_PARALLEL;
bus->flags = flags;
break;
-   case V4L2_FWNODE_BUS_TYPE_BT656:
+   case V4L2_MBUS_BT656:
vep->bus_type = V4L2_MBUS_BT656;
bus->flags = flags & ~PARALLEL_MBUS_FLAGS;
break;
@@ -288,7 +345,7 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
 static void
 v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode,
struct v4l2_fwnode_endpoint *vep,
-   enum v4l2_fwnode_bus_type bus_type)
+   enum v4l2_mbus_type bus_type)
 {
struct v4l2_fwnode_bus_mipi_csi1 *bus = >bus.mipi_csi1;
   

[PATCH 17/21] v4l: fwnode: Print bus type

2018-07-23 Thread Sakari Ailus
Print bus type either as set by the driver or as parsed from the bus-type
property, as well as the guessed V4L2 media bus type.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 0a9d85b3892f..8914abd20ee8 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -99,6 +99,36 @@ v4l2_fwnode_bus_type_to_mbus(enum v4l2_fwnode_bus_type type)
return conv ? conv->mbus_type : V4L2_MBUS_UNKNOWN;
 }
 
+static const char *
+v4l2_fwnode_bus_type_to_string(enum v4l2_fwnode_bus_type type)
+{
+   const struct v4l2_fwnode_bus_conv *conv =
+   get_v4l2_fwnode_bus_conv_by_fwnode_bus(type);
+
+   return conv ? conv->name : "not found";
+}
+
+static const struct v4l2_fwnode_bus_conv *
+get_v4l2_fwnode_bus_conv_by_mbus(enum v4l2_mbus_type type)
+{
+   unsigned int i;
+
+   for (i = 0; i < ARRAY_SIZE(busses); i++)
+   if (busses[i].mbus_type == type)
+   return [i];
+
+   return NULL;
+}
+
+static const char *
+v4l2_fwnode_mbus_type_to_string(enum v4l2_mbus_type type)
+{
+   const struct v4l2_fwnode_bus_conv *conv =
+   get_v4l2_fwnode_bus_conv_by_mbus(type);
+
+   return conv ? conv->name : "not found";
+}
+
 static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
   struct v4l2_fwnode_endpoint *vep,
   enum v4l2_mbus_type bus_type)
@@ -398,6 +428,10 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
memset(>base, 0, sizeof(vep->base));
 
fwnode_property_read_u32(fwnode, "bus-type", _type);
+   pr_debug("fwnode video bus type %s (%u), mbus type %s (%u)\n",
+v4l2_fwnode_bus_type_to_string(bus_type), bus_type,
+v4l2_fwnode_mbus_type_to_string(vep->bus_type),
+vep->bus_type);
 
mbus_type = v4l2_fwnode_bus_type_to_mbus(bus_type);
 
@@ -415,6 +449,10 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
if (vep->bus_type == V4L2_MBUS_UNKNOWN)
return -EINVAL;
 
+   pr_debug("assuming media bus type %s (%u)\n",
+v4l2_fwnode_mbus_type_to_string(vep->bus_type),
+vep->bus_type);
+
break;
 
case V4L2_MBUS_CCP2:
-- 
2.11.0



[PATCH 08/21] v4l: fwnode: Make use of newly specified bus types

2018-07-23 Thread Sakari Ailus
Make use of bus type specified for an endpoint.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 85f409808042..e62a1fcabd8f 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -123,8 +123,16 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
return 0;
 }
 
+#define PARALLEL_MBUS_FLAGS (V4L2_MBUS_HSYNC_ACTIVE_HIGH | \
+V4L2_MBUS_HSYNC_ACTIVE_LOW |   \
+V4L2_MBUS_VSYNC_ACTIVE_HIGH |  \
+V4L2_MBUS_VSYNC_ACTIVE_LOW |   \
+V4L2_MBUS_FIELD_EVEN_HIGH |\
+V4L2_MBUS_FIELD_EVEN_LOW)
+
 static void v4l2_fwnode_endpoint_parse_parallel_bus(
-   struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep)
+   struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep,
+   enum v4l2_fwnode_bus_type bus_type)
 {
struct v4l2_fwnode_bus_parallel *bus = >bus.parallel;
unsigned int flags = 0;
@@ -192,17 +200,24 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
pr_debug("data-enable-active %s\n", v ? "high" : "low");
}
 
-   if (flags || is_parallel) {
+   switch (bus_type) {
+   default:
bus->flags = flags;
-   if (flags & (V4L2_MBUS_HSYNC_ACTIVE_HIGH |
-V4L2_MBUS_HSYNC_ACTIVE_LOW |
-V4L2_MBUS_VSYNC_ACTIVE_HIGH |
-V4L2_MBUS_VSYNC_ACTIVE_LOW |
-V4L2_MBUS_FIELD_EVEN_HIGH |
-V4L2_MBUS_FIELD_EVEN_LOW))
-   vep->bus_type = V4L2_MBUS_PARALLEL;
-   else
-   vep->bus_type = V4L2_MBUS_BT656;
+   if (flags || is_parallel) {
+   if (flags & PARALLEL_MBUS_FLAGS)
+   vep->bus_type = V4L2_MBUS_PARALLEL;
+   else
+   vep->bus_type = V4L2_MBUS_BT656;
+   }
+   break;
+   case V4L2_FWNODE_BUS_TYPE_PARALLEL:
+   vep->bus_type = V4L2_MBUS_PARALLEL;
+   bus->flags = flags;
+   break;
+   case V4L2_FWNODE_BUS_TYPE_BT656:
+   vep->bus_type = V4L2_MBUS_BT656;
+   bus->flags = flags & ~PARALLEL_MBUS_FLAGS;
+   break;
}
 }
 
@@ -263,7 +278,8 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
return rval;
 
if (vep->bus_type == V4L2_MBUS_UNKNOWN)
-   v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep);
+   v4l2_fwnode_endpoint_parse_parallel_bus(
+   fwnode, vep, V4L2_MBUS_UNKNOWN);
 
return vep->bus_type == V4L2_MBUS_UNKNOWN ? -EINVAL : 0;
case V4L2_FWNODE_BUS_TYPE_CCP2:
@@ -271,6 +287,14 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
v4l2_fwnode_endpoint_parse_csi1_bus(fwnode, vep, bus_type);
 
return 0;
+   case V4L2_FWNODE_BUS_TYPE_CSI2_DPHY:
+   vep->bus_type = V4L2_MBUS_CSI2_DPHY;
+   return v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep);
+   case V4L2_FWNODE_BUS_TYPE_PARALLEL:
+   case V4L2_FWNODE_BUS_TYPE_BT656:
+   v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep, bus_type);
+
+   return 0;
default:
pr_warn("unsupported bus type %u\n", bus_type);
return -EINVAL;
-- 
2.11.0



[PATCH 12/21] v4l: fwnode: Support default CSI-2 lane mapping for drivers

2018-07-23 Thread Sakari Ailus
Most hardware doesn't support re-mapping of the CSI-2 lanes. Especially
sensor drivers have a default number of lanes. Instead of requiring the
caller (the driver) to provide such a unit mapping, provide one if no
mapping is configured.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index ed147b6fd315..19f4e331c7d8 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -47,20 +47,35 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
   enum v4l2_fwnode_bus_type 
bus_type)
 {
struct v4l2_fwnode_bus_mipi_csi2 *bus = >bus.mipi_csi2;
-   bool have_clk_lane = false, have_lane_polarities = false;
+   bool have_clk_lane = false, have_data_lanes = false,
+   have_lane_polarities = false;
unsigned int flags = 0, lanes_used = 0;
u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
+   u32 clock_lane = 0;
unsigned int num_data_lanes = 0;
+   bool use_default_lane_mapping = false;
unsigned int i;
u32 v;
int rval;
 
if (bus_type == V4L2_FWNODE_BUS_TYPE_CSI2_DPHY) {
+   use_default_lane_mapping = true;
+
num_data_lanes = min_t(u32, bus->num_data_lanes,
   V4L2_FWNODE_CSI2_MAX_DATA_LANES);
 
-   for (i = 0; i < num_data_lanes; i++)
+   clock_lane = bus->clock_lane;
+   if (clock_lane)
+   use_default_lane_mapping = false;
+
+   for (i = 0; i < num_data_lanes; i++) {
array[i] = bus->data_lanes[i];
+   if (array[i])
+   use_default_lane_mapping = false;
+   }
+
+   if (use_default_lane_mapping)
+   pr_debug("using default lane mapping\n");
}
 
rval = fwnode_property_read_u32_array(fwnode, "data-lanes", NULL, 0);
@@ -70,15 +85,21 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
 
fwnode_property_read_u32_array(fwnode, "data-lanes", array,
   num_data_lanes);
+
+   have_data_lanes = true;
}
 
for (i = 0; i < num_data_lanes; i++) {
-   if (lanes_used & BIT(array[i]))
-   pr_warn("duplicated lane %u in data-lanes\n",
-   array[i]);
+   if (lanes_used & BIT(array[i])) {
+   if (have_data_lanes || !use_default_lane_mapping)
+   pr_warn("duplicated lane %u in data-lanes, 
using defaults\n",
+   array[i]);
+   use_default_lane_mapping = true;
+   }
lanes_used |= BIT(array[i]);
 
-   pr_debug("lane %u position %u\n", i, array[i]);
+   if (have_data_lanes)
+   pr_debug("lane %u position %u\n", i, array[i]);
}
 
rval = fwnode_property_read_u32_array(fwnode, "lane-polarities", NULL,
@@ -94,13 +115,16 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
}
 
if (!fwnode_property_read_u32(fwnode, "clock-lanes", )) {
-   if (lanes_used & BIT(v))
-   pr_warn("duplicated lane %u in clock-lanes\n", v);
-   lanes_used |= BIT(v);
-
-   bus->clock_lane = v;
-   have_clk_lane = true;
+   clock_lane = v;
pr_debug("clock lane position %u\n", v);
+   have_clk_lane = true;
+   }
+
+   if (lanes_used & BIT(clock_lane)) {
+   if (have_clk_lane || !use_default_lane_mapping)
+   pr_warn("duplicated lane %u in clock-lanes, using 
defaults\n",
+   v);
+   use_default_lane_mapping = true;
}
 
if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
@@ -115,8 +139,16 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
bus->flags = flags;
vep->bus_type = V4L2_MBUS_CSI2_DPHY;
bus->num_data_lanes = num_data_lanes;
-   for (i = 0; i < num_data_lanes; i++)
-   bus->data_lanes[i] = array[i];
+
+   if (use_default_lane_mapping) {
+   bus->clock_lane = 0;
+   for (i = 0; i < num_data_lanes; i++)
+   bus->data_lanes[i] = 1 + i;
+   } else {
+   bus->clock_lane = clock_lane;
+   for (i = 0; i < num_data_lanes; i++)
+   

[PATCH 20/21] v4l: fwnode: Update V4L2 fwnode endpoint parsing documentation

2018-07-23 Thread Sakari Ailus
The semantics of v4l2_fwnode_endpoint_parse() and
v4l2_fwnode_endpoint_alloc_parse() have changed slightly: they now take
the bus type from the user as well as a default configuration for the bus
that shall reflect the DT binding defaults. Document this.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-fwnode.c |  3 ++-
 include/media/v4l2-fwnode.h   | 28 +++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 04ddac86aec2..39491c6435ce 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -484,7 +484,8 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
break;
case V4L2_MBUS_PARALLEL:
case V4L2_MBUS_BT656:
-   v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep, 
vep->bus_type);
+   v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep,
+   vep->bus_type);
 
break;
default:
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index 4cef723a6ad9..7cad3b2756ec 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -139,6 +139,20 @@ struct v4l2_fwnode_link {
  * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a
  * reference to @fwnode.
  *
+ * The caller is responsible for assigning @vep.bus_type to a valid media bus
+ * type, or alternatively V4L2_MBUS_UNKNOWN. Depending on the hardware, the
+ * information may also be read from the firmware. As a compatibility means
+ * guessing the bus type is also supported. Mismatching bus types in the V4L2
+ * fwnode endpoint and in firmware will also yield an error (-ENXIO).
+ *
+ * The user may also set the default parameters for the bus if the bus type is
+ * explicitly set by the user. In particular, the user may set the default
+ * number of CSI-2 lanes but without assigning lane mapping, in which case the
+ * defaults (clock lane 0, data lanes from 1 onwards) will be used. The 
defaults
+ * shall reflect the defaults defined in the DT binding documentation.
+ *
+ * The function does not change the V4L2 fwnode endpoint state if it fails.
+ *
  * NOTE: This function does not parse properties the size of which is variable
  * without a low fixed limit. Please use v4l2_fwnode_endpoint_alloc_parse() in
  * new drivers instead.
@@ -171,7 +185,19 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint 
*vep);
  * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a
  * reference to @fwnode.
  *
- * The caller must set the bus_type field of @vep to zero.
+ * The caller is responsible for assigning @vep.bus_type to a valid media bus
+ * type, or alternatively V4L2_MBUS_UNKNOWN. Depending on the hardware, the
+ * information may also be read from the firmware. As a compatibility means
+ * guessing the bus type is also supported. Mismatching bus types in the V4L2
+ * fwnode endpoint and in firmware will also yield an error (-ENXIO).
+ *
+ * The user may also set the default parameters for the bus if the bus type is
+ * explicitly set by the user. In particular, the user may set the default
+ * number of CSI-2 lanes but without assigning lane mapping, in which case the
+ * defaults (clock lane 0, data lanes from 1 onwards) will be used. The 
defaults
+ * shall reflect the defaults defined in the DT binding documentation.
+ *
+ * The function does not change the V4L2 fwnode endpoint state if it fails.
  *
  * v4l2_fwnode_endpoint_alloc_parse() has two important differences to
  * v4l2_fwnode_endpoint_parse():
-- 
2.11.0



[PATCH 19/21] v4l: fwnode: Support parsing of CSI-2 C-PHY endpoints

2018-07-23 Thread Sakari Ailus
The V4L2 fwnode framework only parsed CSI-2 D-PHY endpoints while C-PHY
support wasn't there. Also parse endpoints for media bus type
V4L2_MBUS_CSI2_CPHY.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 56e3b6395171..04ddac86aec2 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -145,7 +145,8 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
u32 v;
int rval;
 
-   if (bus_type == V4L2_MBUS_CSI2_DPHY) {
+   if (bus_type == V4L2_MBUS_CSI2_DPHY ||
+   bus_type == V4L2_MBUS_CSI2_CPHY) {
use_default_lane_mapping = true;
 
num_data_lanes = min_t(u32, bus->num_data_lanes,
@@ -221,10 +222,12 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct 
fwnode_handle *fwnode,
flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
}
 
-   if (bus_type == V4L2_MBUS_CSI2_DPHY || lanes_used ||
+   if (bus_type == V4L2_MBUS_CSI2_DPHY ||
+   bus_type == V4L2_MBUS_CSI2_CPHY || lanes_used ||
have_clk_lane || (flags & ~V4L2_MBUS_CSI2_CONTINUOUS_CLOCK)) {
bus->flags = flags;
-   vep->bus_type = V4L2_MBUS_CSI2_DPHY;
+   if (bus_type == V4L2_MBUS_UNKNOWN)
+   vep->bus_type = V4L2_MBUS_CSI2_DPHY;
bus->num_data_lanes = num_data_lanes;
 
if (use_default_lane_mapping) {
@@ -472,6 +475,7 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
break;
 
case V4L2_MBUS_CSI2_DPHY:
+   case V4L2_MBUS_CSI2_CPHY:
rval = v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep,
   vep->bus_type);
if (rval)
-- 
2.11.0



[PATCH 07/21] v4l: mediabus: Recognise CSI-2 D-PHY and C-PHY

2018-07-23 Thread Sakari Ailus
The CSI-2 bus may use either D-PHY or C-PHY. Make this visible in media
bus enum.

Signed-off-by: Sakari Ailus 
---
 drivers/gpu/ipu-v3/ipu-csi.c | 2 +-
 drivers/media/i2c/adv7180.c  | 2 +-
 drivers/media/i2c/ov5640.c   | 4 ++--
 drivers/media/i2c/ov5645.c   | 2 +-
 drivers/media/i2c/ov7251.c   | 4 ++--
 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
 drivers/media/i2c/s5k5baf.c  | 4 ++--
 drivers/media/i2c/s5k6aa.c   | 2 +-
 drivers/media/i2c/smiapp/smiapp-core.c   | 2 +-
 drivers/media/i2c/soc_camera/ov5642.c| 2 +-
 drivers/media/i2c/tc358743.c | 4 ++--
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +-
 drivers/media/platform/cadence/cdns-csi2rx.c | 2 +-
 drivers/media/platform/cadence/cdns-csi2tx.c | 2 +-
 drivers/media/platform/marvell-ccic/mcam-core.c  | 4 ++--
 drivers/media/platform/marvell-ccic/mmp-driver.c | 2 +-
 drivers/media/platform/omap3isp/isp.c| 2 +-
 drivers/media/platform/pxa_camera.c  | 2 +-
 drivers/media/platform/rcar-vin/rcar-csi2.c  | 2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c | 2 +-
 drivers/media/platform/stm32/stm32-dcmi.c| 2 +-
 drivers/media/platform/ti-vpe/cal.c  | 2 +-
 drivers/media/v4l2-core/v4l2-fwnode.c| 2 +-
 drivers/staging/media/imx/imx-media-csi.c| 2 +-
 drivers/staging/media/imx/imx6-mipi-csi2.c   | 2 +-
 drivers/staging/media/imx074/imx074.c| 2 +-
 include/media/v4l2-mediabus.h| 6 --
 27 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index caa05b0702e1..4bc12d7b0b49 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -344,7 +344,7 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config 
*csicfg,
else
csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE;
break;
-   case V4L2_MBUS_CSI2:
+   case V4L2_MBUS_CSI2_DPHY:
/*
 * MIPI CSI-2 requires non gated clock mode, all other
 * parameters are not applicable for MIPI CSI-2 bus.
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 25d24a3f10a7..8241eb0c095d 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -742,7 +742,7 @@ static int adv7180_g_mbus_config(struct v4l2_subdev *sd,
struct adv7180_state *state = to_state(sd);
 
if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
-   cfg->type = V4L2_MBUS_CSI2;
+   cfg->type = V4L2_MBUS_CSI2_DPHY;
cfg->flags = V4L2_MBUS_CSI2_1_LANE |
V4L2_MBUS_CSI2_CHANNEL_0 |
V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 071f4bc240ca..942531aaae92 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -1786,7 +1786,7 @@ static int ov5640_set_power(struct ov5640_dev *sensor, 
bool on)
if (ret)
goto power_off;
 
-   if (sensor->ep.bus_type == V4L2_MBUS_CSI2) {
+   if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
/*
 * start streaming briefly followed by stream off in
 * order to coax the clock lane into LP-11 state.
@@ -2550,7 +2550,7 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int 
enable)
goto out;
}
 
-   if (sensor->ep.bus_type == V4L2_MBUS_CSI2)
+   if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY)
ret = ov5640_set_stream_mipi(sensor, enable);
else
ret = ov5640_set_stream_dvp(sensor, enable);
diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index 1722cdab0daf..5eba8dd7222b 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1127,7 +1127,7 @@ static int ov5645_probe(struct i2c_client *client,
return ret;
}
 
-   if (ov5645->ep.bus_type != V4L2_MBUS_CSI2) {
+   if (ov5645->ep.bus_type != V4L2_MBUS_CSI2_DPHY) {
dev_err(dev, "invalid bus type, must be CSI2\n");
return -EINVAL;
}
diff --git a/drivers/media/i2c/ov7251.c b/drivers/media/i2c/ov7251.c
index d3ebb7529fca..0c10203f822b 100644
--- a/drivers/media/i2c/ov7251.c
+++ b/drivers/media/i2c/ov7251.c
@@ -1279,9 +1279,9 @@ static int ov7251_probe(struct i2c_client *client)
return ret;
}
 
-   if (ov7251->ep.bus_type != V4L2_MBUS_CSI2) {
+   if (ov7251->ep.bus_type != V4L2_MBUS_CSI2_DPHY) {
dev_err(dev, "invalid bus 

[PATCH 13/21] v4l: fwnode: Parse the graph endpoint as last

2018-07-23 Thread Sakari Ailus
Parsing the graph endpoint is always successful; therefore parse it as
last.

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

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 19f4e331c7d8..1e64182b74dd 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -308,7 +308,11 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
 
pr_debug("= begin V4L2 endpoint properties\n");
 
-   fwnode_graph_parse_endpoint(fwnode, >base);
+   /*
+* Zero the fwnode graph endpoint memory in case we don't end up parsing
+* the endpoint.
+*/
+   memset(>base, 0, sizeof(vep->base));
 
/* Zero fields from bus_type to until the end */
memset(>bus_type, 0, sizeof(*vep) -
@@ -327,25 +331,37 @@ static int __v4l2_fwnode_endpoint_parse(struct 
fwnode_handle *fwnode,
v4l2_fwnode_endpoint_parse_parallel_bus(
fwnode, vep, V4L2_MBUS_UNKNOWN);
 
-   return vep->bus_type == V4L2_MBUS_UNKNOWN ? -EINVAL : 0;
+   if (vep->bus_type == V4L2_MBUS_UNKNOWN)
+   return -EINVAL;
+
+   break;
+
case V4L2_FWNODE_BUS_TYPE_CCP2:
case V4L2_FWNODE_BUS_TYPE_CSI1:
v4l2_fwnode_endpoint_parse_csi1_bus(fwnode, vep, bus_type);
+   break;
 
-   return 0;
case V4L2_FWNODE_BUS_TYPE_CSI2_DPHY:
vep->bus_type = V4L2_MBUS_CSI2_DPHY;
-   return v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep,
+   rval = v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep,
   bus_type);
+   if (rval)
+   return rval;
+
+   break;
case V4L2_FWNODE_BUS_TYPE_PARALLEL:
case V4L2_FWNODE_BUS_TYPE_BT656:
v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep, bus_type);
 
-   return 0;
+   break;
default:
pr_warn("unsupported bus type %u\n", bus_type);
return -EINVAL;
}
+
+   fwnode_graph_parse_endpoint(fwnode, >base);
+
+   return 0;
 }
 
 int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
-- 
2.11.0



Re: [PATCH v2 00/16] i.MX media mem2mem scaler

2018-07-23 Thread Philipp Zabel
Hi Steve,

On Sun, 2018-07-22 at 11:30 -0700, Steve Longerbeam wrote:
[...]
> To aid in debugging this I created branch 'imx-mem2mem.stevel' in my
> mediatree fork on github. I moved the mem2mem driver to the beginning
> and added a few patches:
> 
> d317a7771c ("gpu: ipu-cpmem: add WARN_ON_ONCE() for unaligned dma buffers")
> b4362162c0 ("media: imx: mem2mem: Use ipu_image_convert_adjust in try 
> format")
> 4758be0cf8 ("gpu: ipu-v3: image-convert: Fix width/height alignment")
> d069163c7f ("gpu: ipu-v3: image-convert: Fix input bytesperline clamp in 
> adjust")
> 
> (feel free to squash some of those if you agree with them for v3).

Thank you, I've squashed them where it made sense:

- "media: imx: mem2mem: Use ipu_image_convert_adjust in try format"
  into "media: imx: add mem2mem device" so it could be merged
  independently,
- "gpu: ipu-v3: image-convert: Fix width/height alignment" into
  "gpu: ipu-v3: image-convert: relax alignment restrictions", which
  itself is squashed together from "gpu: ipu-v3: image-convert: relax
  input alignment restrictions" and "gpu: ipu-v3: image-convert: relax
  output alignment restrictions", and
- "gpu: ipu-v3: image-convert: Fix input bytesperline clamp in adjust"
  into "gpu: ipu-v3: image-convert: fix bytesperline adjustment".

I've added some fixes and limited output tile top/left alignment to 8x8
IRT block size if the rotator is being used, and dropped the current
state into this branch:

  git://git.pengutronix.de/pza/linux imx-mem2mem

regards
Philipp


Re: [RFC] media: thermal I2C cameras metadata

2018-07-23 Thread Sakari Ailus
Hi Matt,

On Sun, Jul 15, 2018 at 11:05:42PM -0700, Matt Ranostay wrote:
> Hello et all,
> 
> So currently working with some thermal sensors that have coefficients
> that needs to be passed back to userspace that aren't related to the
> pixel data but are required to normalize to remove scan patterns and
> temp gradients. Was wondering the best way to do this, and hope it
> isn't some is kludge of the close captioning, or just passing raw data
> as another column line.

Are you referring to the EEPROM content or something else?

For EEPROM, I could think of just exposing the EEPROM to the user space
as-is using the NVMEM API. This information is very, very device specific
and therefore using a generic interface to access individual values there
isn't really useful.

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


[PATCH 2/2] dw9807-vcm: Recognise this is just the VCM bit of the device

2018-07-23 Thread Sakari Ailus
The dw9807 contains a voice coil lens driver as well as an EEPROM. This
driver is just for the VCM. Reflect this in the driver's name --- this is
already the case for the compatible string, for instance.

Signed-off-by: Sakari Ailus 
---
 drivers/media/i2c/Kconfig| 2 +-
 drivers/media/i2c/Makefile   | 2 +-
 drivers/media/i2c/{dw9807.c => dw9807-vcm.c} | 0
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename drivers/media/i2c/{dw9807.c => dw9807-vcm.c} (100%)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 79bbb39f5b0d..20d53c9aa709 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -346,7 +346,7 @@ config VIDEO_DW9714
  capability. This is designed for linear control of
  voice coil motors, controlled via I2C serial interface.
 
-config VIDEO_DW9807
+config VIDEO_DW9807_VCM
tristate "DW9807 lens voice coil support"
depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER
depends on VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index aa2d793b80cc..39ad6883e0a9 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -25,7 +25,7 @@ obj-$(CONFIG_VIDEO_SAA6752HS) += saa6752hs.o
 obj-$(CONFIG_VIDEO_AD5820)  += ad5820.o
 obj-$(CONFIG_VIDEO_AK7375)  += ak7375.o
 obj-$(CONFIG_VIDEO_DW9714)  += dw9714.o
-obj-$(CONFIG_VIDEO_DW9807)  += dw9807.o
+obj-$(CONFIG_VIDEO_DW9807_VCM)  += dw9807-vcm.o
 obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o
 obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o
 obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o
diff --git a/drivers/media/i2c/dw9807.c b/drivers/media/i2c/dw9807-vcm.c
similarity index 100%
rename from drivers/media/i2c/dw9807.c
rename to drivers/media/i2c/dw9807-vcm.c
-- 
2.11.0



[PATCH 1/2] dt-bindings: dw9714, dw9807-vcm: Add files to MAINTAINERS, rename files

2018-07-23 Thread Sakari Ailus
Add the DT binding documentation for dw9714 and dw9807-vcm to the
MAINTAINERS file. The dw9807-vcm binding documentation file is renamed to
match the dw9807's VCM bit's compatible string.

Signed-off-by: Sakari Ailus 
---
 .../bindings/media/i2c/{dongwoon,dw9807.txt => dongwoon,dw9807-vcm.txt} | 0
 MAINTAINERS | 2 ++
 2 files changed, 2 insertions(+)
 rename Documentation/devicetree/bindings/media/i2c/{dongwoon,dw9807.txt => 
dongwoon,dw9807-vcm.txt} (100%)

diff --git a/Documentation/devicetree/bindings/media/i2c/dongwoon,dw9807.txt 
b/Documentation/devicetree/bindings/media/i2c/dongwoon,dw9807-vcm.txt
similarity index 100%
rename from Documentation/devicetree/bindings/media/i2c/dongwoon,dw9807.txt
rename to Documentation/devicetree/bindings/media/i2c/dongwoon,dw9807-vcm.txt
diff --git a/MAINTAINERS b/MAINTAINERS
index bbd9b9b3d74f..44e917de2c8c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4410,6 +4410,7 @@ L:linux-media@vger.kernel.org
 T: git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/i2c/dw9714.c
+F: Documentation/devicetree/bindings/media/i2c/dongwoon,dw9714.txt
 
 DONGWOON DW9807 LENS VOICE COIL DRIVER
 M: Sakari Ailus 
@@ -4417,6 +4418,7 @@ L:linux-media@vger.kernel.org
 T: git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/i2c/dw9807.c
+F: Documentation/devicetree/bindings/media/i2c/dongwoon,dw9807-vcm.txt
 
 DOUBLETALK DRIVER
 M: "James R. Van Zandt" 
-- 
2.11.0



[PATCH 0/2] dw9807 bindings and driver are just for VCM

2018-07-23 Thread Sakari Ailus
Hi,

I though of writing these two small patches to rename the dw9807 bindings
and driver to reflect what's apparent in the compatible string: this is
just the VCM part.

Sakari Ailus (2):
  dt-bindings: dw9714, dw9807-vcm: Add files to MAINTAINERS, rename
files
  dw9807-vcm: Recognise this is just the VCM bit of the device

 .../bindings/media/i2c/{dongwoon,dw9807.txt => dongwoon,dw9807-vcm.txt} | 0
 MAINTAINERS | 2 ++
 drivers/media/i2c/Kconfig   | 2 +-
 drivers/media/i2c/Makefile  | 2 +-
 drivers/media/i2c/{dw9807.c => dw9807-vcm.c}| 0
 5 files changed, 4 insertions(+), 2 deletions(-)
 rename Documentation/devicetree/bindings/media/i2c/{dongwoon,dw9807.txt => 
dongwoon,dw9807-vcm.txt} (100%)
 rename drivers/media/i2c/{dw9807.c => dw9807-vcm.c} (100%)

-- 
2.11.0



Re: [PATCH v2 00/16] i.MX media mem2mem scaler

2018-07-23 Thread Philipp Zabel
On Mon, 2018-07-23 at 11:29 +0200, Philipp Zabel wrote:
[...]
> > Also, I'm trying to parse the functions find_best_seam() and 
> > find_seams(). Can
> > you provide some more background on the behavior of those functions?
> 
> The hardware limits us to restart linear sampling at zero with each
> tile, so find_seams() tries to find the (horizontal and vertical) output
> positions where the corresponding input sampling positions are closest
> to integer values.
> The distance between the ideal fractional input sampling position and
> the actual integer sampling position that can be achieved is the amount
> of distortion we have to introduce (by slightly stretching one input
> tile and slightly shrinking the other) to completely hide the visible
> seams.

Actually, this is not all of it. In addition to being an integer, the
input sampling position at seam start is still subject to alignment
restrictions, so the actual value that is minimized is the difference
between the ideal fractional input sampling position and the closest
aligned input position.

regards
Philipp


[GIT PULL FOR v4.19] vicodec: the Virtual Codec driver

2018-07-23 Thread Hans Verkuil
Hi Mauro,

This is the pull request for the new vicodec driver. The cover letter is
here:

https://www.mail-archive.com/linux-media@vger.kernel.org/msg133594.html

One request: the vicodec-codec.h header refers to Tom's report on the Fast Walsh
Hadamard Transform:

https://hverkuil.home.xs4all.nl/fwht.pdf

Can you copy this pdf and put it up somewhere on linuxtv.org and update the
link in the header so it points to linuxtv.org?

With all the activities ongoing it will be very useful to have this driver in
the kernel so we can test and verify APIs.

Regards,

Hans

The following changes since commit 39fbb88165b2bbbc77ea7acab5f10632a31526e6:

  media: bpf: ensure bpf program is freed on detach (2018-07-13 11:07:29 -0400)

are available in the Git repository at:

  git://linuxtv.org/hverkuil/media_tree.git vicodec

for you to fetch changes up to 92389fd3ce7cce108b448d76943c71d410ab40c0:

  vicodec: add the virtual codec driver (2018-07-23 11:24:54 +0200)


Hans Verkuil (5):
  media.h: add encoder/decoder functions for codecs
  videodev.h: add PIX_FMT_FWHT for use with vicodec
  v4l2-mem2mem: add v4l2_m2m_last_buf()
  vicodec: add the FWHT software codec
  vicodec: add the virtual codec driver

 Documentation/media/uapi/mediactl/media-types.rst  |   11 +
 Documentation/media/uapi/v4l/pixfmt-compressed.rst |7 +
 MAINTAINERS|8 +
 drivers/media/platform/Kconfig |3 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/vicodec/Kconfig |   13 +
 drivers/media/platform/vicodec/Makefile|4 +
 drivers/media/platform/vicodec/vicodec-codec.c |  797 
+++
 drivers/media/platform/vicodec/vicodec-codec.h |  129 +
 drivers/media/platform/vicodec/vicodec-core.c  | 1506 
+++
 drivers/media/v4l2-core/v4l2-ioctl.c   |1 +
 drivers/media/v4l2-core/v4l2-mem2mem.c |   18 +
 include/media/v4l2-mem2mem.h   |   29 +
 include/uapi/linux/media.h |2 +
 include/uapi/linux/videodev2.h |1 +
 15 files changed, 2530 insertions(+)
 create mode 100644 drivers/media/platform/vicodec/Kconfig
 create mode 100644 drivers/media/platform/vicodec/Makefile
 create mode 100644 drivers/media/platform/vicodec/vicodec-codec.c
 create mode 100644 drivers/media/platform/vicodec/vicodec-codec.h
 create mode 100644 drivers/media/platform/vicodec/vicodec-core.c


Re: [PATCH v2 00/16] i.MX media mem2mem scaler

2018-07-23 Thread Philipp Zabel
Hi Steve,

On Sun, 2018-07-22 at 11:30 -0700, Steve Longerbeam wrote:
> Hi Philipp,
> 
> On 07/19/2018 08:30 AM, Philipp Zabel wrote:
> > Hi,
> > 
> > this is the second version of the i.MX mem2mem scaler series.
> > Patches 8 and 16 have been modified.
> > 
> > Changes since v1:
> >   - Fix inverted allow_overshoot logic
> >   - Correctly switch horizontal / vertical tile alignment when
> > determining seam positions with the 90° rotator active.
> 
> Yes, this fixes the specific rotation test that was broken
> (720x480, UYVY --> 1280x768, UYVY, rotate 90).
> 
> But running more tests on this v2 reveals more issues. I chose a
> somewhat random upscaling-only example as a first try:
> 
> 640x480, YV12 --> full HD 2560x1600, YV12 (no rotation or flip).
>
> This produces division by zero backtraces and the conversion hangs:
> 
> 
> [  131.079978] Division by zero in kernel.
[...]

Thanks, find_best_seam() breaks because it is fed the wrong bottom edge:

--8<--
diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c 
b/drivers/gpu/ipu-v3/ipu-image-convert.c
index 726e3b7390c7..0c47d39adf03 100644
--- a/drivers/gpu/ipu-v3/ipu-image-convert.c
+++ b/drivers/gpu/ipu-v3/ipu-image-convert.c
@@ -806,7 +801,7 @@ static void find_seams(struct ipu_image_convert_ctx *ctx,
/* Start within 1024 lines of the bottom edge */
out_start = max_t(int, 0, out_bottom - 1024);
/* End before having to add more rows above */
-   out_end = min_t(unsigned int, out_right, row * 1024);
+   out_end = min_t(unsigned int, out_bottom, row * 1024);
 
find_best_seam(ctx, out_start, out_end,
   in_top_align, out_top_align, out_height_align,
-->8--

Also we unnecessarily use four tile columns instead of three:

--8<--
diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c 
b/drivers/gpu/ipu-v3/ipu-image-convert.c
index 726e3b7390c7..0c47d39adf03 100644
--- a/drivers/gpu/ipu-v3/ipu-image-convert.c
+++ b/drivers/gpu/ipu-v3/ipu-image-convert.c
@@ -380,12 +380,7 @@ static int alloc_dma_buf(struct ipu_image_convert_priv 
*priv,
 
 static inline int num_stripes(int dim)
 {
-   if (dim <= 1024)
-   return 1;
-   else if (dim <= 2048)
-   return 2;
-   else
-   return 4;
+   return (dim - 1) / 1024 + 1;
 }
 
 /*
-->8--

With that fixed, your test case succeeds.

Unfortunately, just adding rotate=90 makes it hang again. I'll
investigate.

> To aid in debugging this I created branch 'imx-mem2mem.stevel' in my
> mediatree fork on github. I moved the mem2mem driver to the beginning
> and added a few patches:
> 
> d317a7771c ("gpu: ipu-cpmem: add WARN_ON_ONCE() for unaligned dma buffers")
> b4362162c0 ("media: imx: mem2mem: Use ipu_image_convert_adjust in try 
> format")
> 4758be0cf8 ("gpu: ipu-v3: image-convert: Fix width/height alignment")
> d069163c7f ("gpu: ipu-v3: image-convert: Fix input bytesperline clamp in 
> adjust")
> 
> (feel free to squash some of those if you agree with them for v3).
>
> By moving the mem2mem driver before the seam avoidance patches, and making
> it independent of the image converter implementation, the driver can be 
> tested with
> and without the seam avoidance changes.

Yes, this makes sense to me. If we merge the mem2mem driver before the
image-convert changes go in, it should be limited to 1024x1024 output,
but if we manage to merge both parts in the same cycle, this should be
fine.

[...]
> Also, I'm trying to parse the functions find_best_seam() and 
> find_seams(). Can
> you provide some more background on the behavior of those functions?

The hardware limits us to restart linear sampling at zero with each
tile, so find_seams() tries to find the (horizontal and vertical) output
positions where the corresponding input sampling positions are closest
to integer values.
The distance between the ideal fractional input sampling position and
the actual integer sampling position that can be achieved is the amount
of distortion we have to introduce (by slightly stretching one input
tile and slightly shrinking the other) to completely hide the visible
seams.

find_best_seam() contains the code to find the left (or top) edge for a
single column (or row) that minimizes this distortion, given the right
(or bottom) edge, scaling factor, alignment restrictions, and allowed
range. The range is limited by the maximum tile width (or height).

find_seams() first iterates over all columns, right to left, and calls
find_best_seam() for each column. Each found seam then serves as the
right edge of the next column. Then it iterates over all rows, bottom to
top, again calling find_best_seam() for each row.

The reason we start at the bottom/right edges is that we have to make
sure that burst size / rotator block size align with the bottom/right
edge of the output frame.

regards
Philipp


[GIT PULL FOR v4.19] cec/cec-gpio: add support for 5V testing

2018-07-23 Thread Hans Verkuil
Some displays disable CEC if the HDMI 5V is not detected. In order
to test issues related to this you want to be able to optionally
detect when the 5V line changes in the cec-gpio driver.

This patch series adds support for this feature.

Regards,

Hans

The following changes since commit 39fbb88165b2bbbc77ea7acab5f10632a31526e6:

  media: bpf: ensure bpf program is freed on detach (2018-07-13 11:07:29 -0400)

are available in the Git repository at:

  git://linuxtv.org/hverkuil/media_tree.git cec-5v

for you to fetch changes up to d2c3c626897322f5a343347e805a35e31f7ca08b:

  cec-gpio: support 5v testing (2018-07-23 10:27:40 +0200)


Hans Verkuil (5):
  cec-gpio.txt: add v5-gpios for testing the 5V line
  cec-ioc-dqevent.rst: document the new 5V events
  uapi/linux/cec.h: add 5V events
  cec: add support for 5V signal testing
  cec-gpio: support 5v testing

 Documentation/devicetree/bindings/media/cec-gpio.txt | 22 +
 Documentation/media/uapi/cec/cec-ioc-dqevent.rst | 18 +
 drivers/media/cec/cec-adap.c | 18 -
 drivers/media/cec/cec-api.c  |  8 
 drivers/media/platform/cec-gpio/cec-gpio.c   | 54 
+++
 include/media/cec-pin.h  |  4 
 include/media/cec.h  | 12 +++-
 include/uapi/linux/cec.h |  2 ++
 8 files changed, 128 insertions(+), 10 deletions(-)


[PATCHv2 1/5] cec-gpio.txt: add v5-gpios for testing the 5V line

2018-07-23 Thread Hans Verkuil
In order to debug the HDMI 5V line we need to add a new v5-gpios
property.

Signed-off-by: Hans Verkuil 
Reviewed-by: Rob Herring 
---
Changes since v1:
- Document that hpd-gpios and 5v-gpios are meant for debugging those lines.
---
 .../devicetree/bindings/media/cec-gpio.txt| 22 ---
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/cec-gpio.txt 
b/Documentation/devicetree/bindings/media/cec-gpio.txt
index 12fcd55ed153..47e8d73d32a3 100644
--- a/Documentation/devicetree/bindings/media/cec-gpio.txt
+++ b/Documentation/devicetree/bindings/media/cec-gpio.txt
@@ -4,8 +4,8 @@ The HDMI CEC GPIO module supports CEC implementations where the 
CEC line
 is hooked up to a pull-up GPIO line and - optionally - the HPD line is
 hooked up to another GPIO line.

-Please note: the maximum voltage for the CEC line is 3.63V, for the HPD
-line it is 5.3V. So you may need some sort of level conversion circuitry
+Please note: the maximum voltage for the CEC line is 3.63V, for the HPD and
+5V lines it is 5.3V. So you may need some sort of level conversion circuitry
 when connecting them to a GPIO line.

 Required properties:
@@ -19,18 +19,24 @@ following property is also required:
   - hdmi-phandle - phandle to the HDMI controller, see also cec.txt.

 If the CEC line is not associated with an HDMI receiver/transmitter, then
-the following property is optional:
+the following property is optional and can be used for debugging HPD changes:

   - hpd-gpios: gpio that the HPD line is connected to.

+This property is optional and can be used for debugging changes on the 5V line:
+
+  - v5-gpios: gpio that the 5V line is connected to.
+
 Example for the Raspberry Pi 3 where the CEC line is connected to
-pin 26 aka BCM7 aka CE1 on the GPIO pin header and the HPD line is
-connected to pin 11 aka BCM17 (some level shifter is needed for this!):
+pin 26 aka BCM7 aka CE1 on the GPIO pin header, the HPD line is
+connected to pin 11 aka BCM17 and the 5V line is connected to pin
+15 aka BCM22 (some level shifter is needed for the HPD and 5V lines!):

 #include 

 cec-gpio {
-   compatible = "cec-gpio";
-   cec-gpios = < 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
-   hpd-gpios = < 17 GPIO_ACTIVE_HIGH>;
+   compatible = "cec-gpio";
+   cec-gpios = < 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+   hpd-gpios = < 17 GPIO_ACTIVE_HIGH>;
+   v5-gpios = < 22 GPIO_ACTIVE_HIGH>;
 };
-- 
2.18.0



Re: [PATCH 2/5] videodev.h: add PIX_FMT_FWHT for use with vicodec

2018-07-23 Thread Hans Verkuil
On 21/07/18 19:51, Tom aan de Wiel wrote:
> Hi!
> 
> As of now, the version of the document I have locally is pretty much 
> identical to the one you already linked to.
> I haven't had the time to shape it into a more documentation kind of document 
> instead of the report format it has now.
> However, the report does contain all details and therefore could suffice as 
> documentation for the time being?
OK, then I'll ask Mauro to put up the document I have on linuxtv.org so I can 
refer to it.

Thanks!

Hans

> 
> Tom
> 
> tor. 19. jul. 2018 kl. 17:52 skrev Hans Verkuil  >:
> 
> On 07/19/2018 05:39 PM, Sakari Ailus wrote:
> > On Thu, Jul 19, 2018 at 03:20:22PM +0200, Hans Verkuil wrote:
> >> On 07/19/18 15:15, sakari.ai...@iki.fi  
> wrote:
> >>> On Thu, Jul 19, 2018 at 02:13:50PM +0200, Hans Verkuil wrote:
>  From: Hans Verkuil mailto:hansv...@cisco.com>>
> 
>  Add a new pixelformat for the vicodec software codec using the
>  Fast Walsh Hadamard Transform.
> 
>  Signed-off-by: Hans Verkuil  >
> >>>
> >>> Could you add documentation for this format, please?
> >>>
> >>
> >> ??? It's part of the patch:
> >>
> >> diff --git a/Documentation/media/uapi/v4l/pixfmt-compressed.rst 
> b/Documentation/media/uapi/v4l/pixfmt-compressed.rst
> >> index abec03937bb3..e5419f046b59 100644
> >> --- a/Documentation/media/uapi/v4l/pixfmt-compressed.rst
> >> +++ b/Documentation/media/uapi/v4l/pixfmt-compressed.rst
> >> @@ -95,3 +95,10 @@ Compressed Formats
> >>        - ``V4L2_PIX_FMT_HEVC``
> >>        - 'HEVC'
> >>        - HEVC/H.265 video elementary stream.
> >> +    * .. _V4L2-PIX-FMT-FWHT:
> >> +
> >> +      - ``V4L2_PIX_FMT_FWHT``
> >> +      - 'FWHT'
> >> +      - Video elementary stream using a codec based on the Fast Walsh 
> Hadamard
> >> +        Transform. This codec is implemented by the vicodec ('Virtual 
> Codec')
> >> +    driver.
> >>
> >> Since the whole codec is implemented in the vicodec source I didn't 
> think it
> >> necessary to say more about it.
> >
> > Oh, well. The source is there but user space developers shouldn't need 
> to
> > read it. OTOH it might be that they're also not the primary audience for
> > this driver either. If there's a Wikipedia article you could refer to or
> > such that'd be fine IMO, too.
> >
> > Up to you.
> >
> 
> Tom,
> 
> Do you have a newer version of your document? If not, can I refer to the 
> version
> I have? If it can be put up at the linuxtv.org  
> website, then that takes care of
> the documentation.
> 
> Regards,
> 
>         Hans
> 



Re: [PATCH 16/16] media: imx: add mem2mem device

2018-07-23 Thread Philipp Zabel
On Sun, 2018-07-22 at 11:02 -0700, Steve Longerbeam wrote:
> On 07/16/2018 07:12 AM, Philipp Zabel wrote:
[...]
> > > > +   /*
> > > > +* The IC burst reads 8 pixels at a time. Reading 
> > > > beyond the
> > > > +* end of the line is usually acceptable. Those pixels 
> > > > are
> > > > +* ignored, unless the IC has to write the scaled line 
> > > > in
> > > > +* reverse.
> > > > +*/
> > > > +   if (!ipu_rot_mode_is_irt(ctx->rot_mode) &&
> > > > +   ctx->rot_mode && IPU_ROT_BIT_HFLIP)
> > > > +   walign = 3;
> > > 
> > > This looks wrong. Do you mean:
> > > 
> > > if (ipu_rot_mode_is_irt(ctx->rot_mode) || (ctx->rot_mode & 
> > > IPU_ROT_BIT_HFLIP))
> > >   walign = 3;
> > > else
> > >   walign = 1;
[...]
> > No, I specifically meant (!IRT && HFLIP).
> 
> Right, but there is still a typo:
> 
> if (!ipu_rot_mode_is_irt(ctx->rot_mode) && ctx->rot_mode && IPU_ROT_BIT_HFLIP)
>
> should be:
> 
> if (!ipu_rot_mode_is_irt(ctx->rot_mode) && (ctx->rot_mode & 
> IPU_ROT_BIT_HFLIP))

Ow, yes, thank you.

> > The rotator itself doesn't cause any input alignment restrictions, we
> > just have to make sure that the intermediate tiles after scaling are 8x8
> > aligned.
> > 
> > > Also, why not simply call ipu_image_convert_adjust() in
> > > mem2mem_try_fmt()? If there is something missing in the former
> > > function, then it should be added there, instead of adding the
> > > missing checks in mem2mem_try_fmt().
> > 
> > ipu_image_convert_adjust tries to adjust both input and output image at
> > the same time, here we just have the format of either input or output
> > image. Do you suggest to split this function into an input and an output
> > version?
> 
> See b4362162c0 ("media: imx: mem2mem: Use ipu_image_convert_adjust
> in try format")

Alright, this looks fine to me. I was worried about inter-format
limitations, but the only one seems to be the output size lower bound to
1/4 of the input size. Should S_FMT(OUT) also update the capture format
if adjustments were made to keep a consistent state?

regards
Philipp