[PATCH] [media] mtk-mdp: Fix g_/s_selection capture/compose logic

2017-04-12 Thread Minghsiu Tsai
From: Daniel Kurtz 

Experiments show that the:
 (1) mtk-mdp uses the _MPLANE form of CAPTURE/OUTPUT
 (2) CAPTURE types use CROP targets, and OUTPUT types use COMPOSE targets

Signed-off-by: Daniel Kurtz 
Signed-off-by: Minghsiu Tsai 

---
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 13afe48..8ab7ca0 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -837,12 +837,12 @@ static int mtk_mdp_m2m_g_selection(struct file *file, 
void *fh,
struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
bool valid = false;
 
-   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-   if (mtk_mdp_is_target_compose(s->target))
-   valid = true;
-   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
if (mtk_mdp_is_target_crop(s->target))
valid = true;
+   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+   if (mtk_mdp_is_target_compose(s->target))
+   valid = true;
}
if (!valid) {
mtk_mdp_dbg(1, "[%d] invalid type:%d,%u", ctx->id, s->type,
@@ -907,12 +907,12 @@ static int mtk_mdp_m2m_s_selection(struct file *file, 
void *fh,
int ret;
bool valid = false;
 
-   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-   if (s->target == V4L2_SEL_TGT_COMPOSE)
-   valid = true;
-   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
if (s->target == V4L2_SEL_TGT_CROP)
valid = true;
+   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+   if (s->target == V4L2_SEL_TGT_COMPOSE)
+   valid = true;
}
if (!valid) {
mtk_mdp_dbg(1, "[%d] invalid type:%d,%u", ctx->id, s->type,
@@ -925,7 +925,7 @@ static int mtk_mdp_m2m_s_selection(struct file *file, void 
*fh,
if (ret)
return ret;
 
-   if (mtk_mdp_is_target_crop(s->target))
+   if (mtk_mdp_is_target_compose(s->target))
frame = >s_frame;
else
frame = >d_frame;
-- 
1.9.1



cron job: media_tree daily build: WARNINGS

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

Results of the daily build of media_tree:

date:   Thu Apr 13 05:00:14 CEST 2017
media-tree git hash:4aed35ca73f6d9cfd5f7089ba5d04f5fb8623080
media_build git hash:   8a44f033b9899e3193da85b1d3369a9dbfcc9eab
v4l-utils git hash: e748123b973e899cd6f0c08272a165661bd8386f
gcc version:i686-linux-gcc (GCC) 6.2.0
sparse version: v0.5.0-3553-g78b2ea6
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.9.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: WARNINGS
linux-3.11.1-i686: OK
linux-3.12.67-i686: OK
linux-3.13.11-i686: WARNINGS
linux-3.14.9-i686: WARNINGS
linux-3.15.2-i686: WARNINGS
linux-3.16.7-i686: WARNINGS
linux-3.17.8-i686: WARNINGS
linux-3.18.7-i686: WARNINGS
linux-3.19-i686: WARNINGS
linux-4.0.9-i686: WARNINGS
linux-4.1.33-i686: WARNINGS
linux-4.2.8-i686: WARNINGS
linux-4.3.6-i686: WARNINGS
linux-4.4.22-i686: WARNINGS
linux-4.5.7-i686: WARNINGS
linux-4.6.7-i686: WARNINGS
linux-4.7.5-i686: WARNINGS
linux-4.8-i686: OK
linux-4.9-i686: OK
linux-4.10.1-i686: OK
linux-4.11-rc1-i686: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: WARNINGS
linux-3.11.1-x86_64: OK
linux-3.12.67-x86_64: OK
linux-3.13.11-x86_64: WARNINGS
linux-3.14.9-x86_64: WARNINGS
linux-3.15.2-x86_64: WARNINGS
linux-3.16.7-x86_64: WARNINGS
linux-3.17.8-x86_64: WARNINGS
linux-3.18.7-x86_64: WARNINGS
linux-3.19-x86_64: WARNINGS
linux-4.0.9-x86_64: WARNINGS
linux-4.1.33-x86_64: WARNINGS
linux-4.2.8-x86_64: WARNINGS
linux-4.3.6-x86_64: WARNINGS
linux-4.4.22-x86_64: WARNINGS
linux-4.5.7-x86_64: WARNINGS
linux-4.6.7-x86_64: WARNINGS
linux-4.7.5-x86_64: WARNINGS
linux-4.8-x86_64: WARNINGS
linux-4.9-x86_64: WARNINGS
linux-4.10.1-x86_64: WARNINGS
linux-4.11-rc1-x86_64: OK
apps: WARNINGS
spec-git: OK
sparse: WARNINGS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


[PATCH] staging/media: make atomisp vlv2_plat_clock explicitly non-modular

2017-04-12 Thread Paul Gortmaker
The Makefile / Kconfig currently controlling compilation of this code is:

clock/Makefile:obj-$(CONFIG_INTEL_ATOMISP) += vlv2_plat_clock.o

atomisp/Kconfig:menuconfig INTEL_ATOMISP
atomisp/Kconfig:bool "Enable support to Intel MIPI camera drivers"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

Since module_init was already not in use by this driver, the init
ordering remains unchanged with this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information
is already contained at the top of the file in the comments.

Cc: Mauro Carvalho Chehab 
Cc: Greg Kroah-Hartman 
Cc: Alan Cox 
Cc: linux-media@vger.kernel.org
Cc: de...@driverdev.osuosl.org
Signed-off-by: Paul Gortmaker 
---
 .../media/atomisp/platform/clock/vlv2_plat_clock.c  | 21 +
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c 
b/drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c
index 25e939c50aef..a322539d2621 100644
--- a/drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c
+++ b/drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c
@@ -21,7 +21,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include "../../include/linux/vlv2_plat_clock.h"
 
@@ -205,18 +205,10 @@ static int vlv2_plat_clk_probe(struct platform_device 
*pdev)
return 0;
 }
 
-static int vlv2_plat_clk_remove(struct platform_device *pdev)
-{
-   iounmap(pmc_base);
-   pmc_base = NULL;
-   return 0;
-}
-
 static const struct platform_device_id vlv2_plat_clk_id[] = {
{"vlv2_plat_clk", 0},
{}
 };
-MODULE_DEVICE_TABLE(platform, vlv2_plat_clk_id);
 
 static int vlv2_resume(struct device *device)
 {
@@ -241,7 +233,6 @@ static const struct dev_pm_ops vlv2_pm_ops = {
 
 static struct platform_driver vlv2_plat_clk_driver = {
.probe = vlv2_plat_clk_probe,
-   .remove = vlv2_plat_clk_remove,
.id_table = vlv2_plat_clk_id,
.driver = {
.name = "vlv2_plat_clk",
@@ -254,13 +245,3 @@ static int __init vlv2_plat_clk_init(void)
return platform_driver_register(_plat_clk_driver);
 }
 arch_initcall(vlv2_plat_clk_init);
-
-static void __exit vlv2_plat_clk_exit(void)
-{
-   platform_driver_unregister(_plat_clk_driver);
-}
-module_exit(vlv2_plat_clk_exit);
-
-MODULE_AUTHOR("Asutosh Pathak ");
-MODULE_DESCRIPTION("Intel VLV2 platform clock driver");
-MODULE_LICENSE("GPL v2");
-- 
2.11.0



[PATCH 40/40] media: imx: set and propagate empty field, colorimetry params

2017-04-12 Thread Steve Longerbeam
This patch adds a call to imx_media_fill_empty_mbus_fields() in the
*_try_fmt() functions at the sink pads, to set empty field order and
colorimetry parameters.

If the field order is set to ANY, choose the currently set field order
at the sink pad. If the colorspace is set to DEFAULT, choose the
current colorspace at the sink pad.  If any of xfer_func, ycbcr_enc
or quantization are set to DEFAULT, either choose the current sink pad
setting, or the default setting for the new colorspace, if non-DEFAULT
colorspace was given.

Colorimetry is also propagated from sink to source pads anywhere
this has not already been done. The exception is ic-prpencvf at the
source pad, since the Image Converter outputs fixed quantization and
Y`CbCr encoding.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-ic-prp.c  |  5 ++-
 drivers/staging/media/imx/imx-ic-prpencvf.c | 25 +++---
 drivers/staging/media/imx/imx-media-csi.c   | 12 +--
 drivers/staging/media/imx/imx-media-utils.c | 53 +
 drivers/staging/media/imx/imx-media-vdic.c  |  7 ++--
 drivers/staging/media/imx/imx-media.h   |  3 +-
 6 files changed, 95 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index b4d4e48..8baa0d5 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -180,6 +180,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
goto out;
}
 
+   fmt = __prp_get_fmt(priv, cfg, PRP_SINK_PAD, sdformat->which);
+
switch (sdformat->pad) {
case PRP_SINK_PAD:
v4l_bound_align_image(>format.width, MIN_W, MAX_W,
@@ -193,11 +195,12 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
cc = imx_media_find_ipu_format(code, CS_SEL_ANY);
sdformat->format.code = cc->codes[0];
}
+
+   imx_media_fill_empty_mbus_fields(>format, fmt);
break;
case PRP_SRC_PAD_PRPENC:
case PRP_SRC_PAD_PRPVF:
/* Output pads mirror input pad */
-   fmt = __prp_get_fmt(priv, cfg, PRP_SINK_PAD, sdformat->which);
sdformat->format = *fmt;
break;
}
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 860b406..cdfb51a 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -772,6 +772,8 @@ static void prp_try_fmt(struct prp_priv *priv,
struct v4l2_subdev_format *sdformat,
const struct imx_media_pixfmt **cc)
 {
+   struct v4l2_mbus_framefmt *infmt;
+
*cc = imx_media_find_ipu_format(sdformat->format.code, CS_SEL_ANY);
if (!*cc) {
u32 code;
@@ -781,11 +783,9 @@ static void prp_try_fmt(struct prp_priv *priv,
sdformat->format.code = (*cc)->codes[0];
}
 
-   if (sdformat->pad == PRPENCVF_SRC_PAD) {
-   struct v4l2_mbus_framefmt *infmt =
-   __prp_get_fmt(priv, cfg, PRPENCVF_SINK_PAD,
- sdformat->which);
+   infmt = __prp_get_fmt(priv, cfg, PRPENCVF_SINK_PAD, sdformat->which);
 
+   if (sdformat->pad == PRPENCVF_SRC_PAD) {
if (sdformat->format.field != V4L2_FIELD_NONE)
sdformat->format.field = infmt->field;
 
@@ -804,12 +804,29 @@ static void prp_try_fmt(struct prp_priv *priv,
  >format.height,
  infmt->height / 4, MAX_H_SRC,
  H_ALIGN_SRC, S_ALIGN);
+
+   /*
+* The Image Converter produces fixed quantization
+* (full range for RGB, limited range for YUV), and
+* uses a fixed Y`CbCr encoding (V4L2_YCBCR_ENC_601).
+* For colorspace and transfer func, just propagate
+* from the sink.
+*/
+   sdformat->format.quantization =
+   ((*cc)->cs != IPUV3_COLORSPACE_YUV) ?
+   V4L2_QUANTIZATION_FULL_RANGE :
+   V4L2_QUANTIZATION_LIM_RANGE;
+   sdformat->format.ycbcr_enc = V4L2_YCBCR_ENC_601;
+   sdformat->format.colorspace = infmt->colorspace;
+   sdformat->format.xfer_func = infmt->xfer_func;
} else {
v4l_bound_align_image(>format.width,
  MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
  >format.height,
  MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
  S_ALIGN);
+
+   imx_media_fill_empty_mbus_fields(>format, infmt);
}
 }
 
diff --git 

Re: [PATCH] [media] imx: csi: retain current field order and colorimetry setting as default

2017-04-12 Thread Steve Longerbeam



On 04/06/2017 08:25 AM, Philipp Zabel wrote:

On Thu, 2017-04-06 at 16:10 +0100, Russell King - ARM Linux wrote:

On Thu, Apr 06, 2017 at 05:01:52PM +0200, Philipp Zabel wrote:

On Thu, 2017-04-06 at 15:05 +0100, Russell King - ARM Linux wrote:

On Thu, Apr 06, 2017 at 03:55:29PM +0200, Philipp Zabel wrote:

+
+   /* Retain current field setting as default */
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = fmt->field;
+
+   /* Retain current colorspace setting as default */
+   if (sdformat->format.colorspace == V4L2_COLORSPACE_DEFAULT) {
+   sdformat->format.colorspace = fmt->colorspace;
+   if (sdformat->format.xfer_func == V4L2_XFER_FUNC_DEFAULT)
+   sdformat->format.xfer_func = fmt->xfer_func;
+   if (sdformat->format.ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT)
+   sdformat->format.ycbcr_enc = fmt->ycbcr_enc;
+   if (sdformat->format.quantization == V4L2_QUANTIZATION_DEFAULT)
+   sdformat->format.quantization = fmt->quantization;
+   } else {
+   if (sdformat->format.xfer_func == V4L2_XFER_FUNC_DEFAULT) {
+   sdformat->format.xfer_func =
+   V4L2_MAP_XFER_FUNC_DEFAULT(
+   sdformat->format.colorspace);
+   }
+   if (sdformat->format.ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT) {
+   sdformat->format.ycbcr_enc =
+   V4L2_MAP_YCBCR_ENC_DEFAULT(
+   sdformat->format.colorspace);
+   }
+   if (sdformat->format.quantization == V4L2_QUANTIZATION_DEFAULT) 
{
+   sdformat->format.quantization =
+   V4L2_MAP_QUANTIZATION_DEFAULT(
+   cc->cs != IPUV3_COLORSPACE_YUV,
+   sdformat->format.colorspace,
+   sdformat->format.ycbcr_enc);
+   }
+   }


Would it make sense for this to be a helper function?


Quite possible, the next subdev that has to set frame_interval on both
pads manually because its upstream source pad doesn't suport
frame_interval might want to do the same.


Hmm.  I'm not sure I agree with this approach.  If a subdev hardware
does not support any modification of the colourspace or field, then
it should not be modifyable at the source pad - it should retain the
propagated settings from the sink pad.


This new code is only relevant for the CSI_SINK_PAD.


I thought I had already sent a patch doing exactly that.


Yes. Right above the modification there is a call to csi_try_fmt which
will already fix up sdformat->format for the source pads. So for the
CSI_SRC_PAD_DIRECT and CSI_SRC_PAD_IDMAC this should amount to a no-op.

If might be better to move this into a separate function and only call
it if sdformat->pad == CSI_SINK_PAD.


I've done this, I will follow with the new patch. Philipp, let me know
if this looks ok to you and I will add your sign-off.

Steve




[PATCH] [media] mceusb: TX -EPIPE (urb status = -32) lockup fix

2017-04-12 Thread A Sun

Bug:

Once IR blasting or mceusb device commands fail with mce_async_callback() TX 
-EPIPE error, all subsequent TX to device then fail with the same error.
...
[  249.986174] mceusb 1-1.2:1.0: requesting 38000 HZ carrier
[  249.986210] mceusb 1-1.2:1.0: send request called (size=0x4)
[  249.986256] mceusb 1-1.2:1.0: send request complete (res=0)
[  249.986403] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[  249.999885] mceusb 1-1.2:1.0: send request called (size=0x3)
[  249.29] mceusb 1-1.2:1.0: send request complete (res=0)
[  250.13] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[  250.019830] mceusb 1-1.2:1.0: send request called (size=0x21)
[  250.019868] mceusb 1-1.2:1.0: send request complete (res=0)
[  250.020007] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
...

Fix:

Message pertains to TX usb halt (stall) condition requiring usb_clear_halt() 
call in non-interrupt context to recover.
Add USB TX halt error handling similar to the RX halt handling case from an 
earlier patch proposal.
Reorder some mceusb code to accommodate TX halt error handling.

This patch depends on the earlier proposed patch set:
  [PATCH 1/3] [media] mceusb: RX -EPIPE (urb status = -32) lockup failure fix
  [PATCH 2/3] [media] mceusb: sporadic RX truncation corruption fix
  [PATCH 3/3] [media] mceusb: fix inaccurate debug buffer dumps and misleading

Tested with:

Linux raspberrypi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l 
GNU/Linux
mceusb 1-1.2:1.0: Registered SMK eHome Infrared Transceiver with mce emulator 
interface version 1
mceusb 1-1.2:1.0: 2 tx ports (0x1 cabled) and 2 rx sensors (0x1 active)

Fault simulation/injection is by executing the following USB operation in a 
mceusb instrumented driver, prior to TX I/O.
retval = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, usb_pipeendpoint(ir->pipe_out),
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(ir->dev, "set halt retval, %d", retval);

After setting halt state for the TX endpoint, perform an lirc "irsend" to 
generate TX traffic to device.
After the TX HALT, the patch restores subsequent TX to working state.
...
[  508.009638] mceusb 1-1.2:1.0: send request called (size=0x3)
[  508.009697] mceusb 1-1.2:1.0: send request complete (res=0)
[  508.009847] mce_async_callback()
[  508.009864] mceusb 1-1.2:1.0: Error: request urb status = -32 (TX HALT)
[  508.009890] mceusb 1-1.2:1.0: kevent 0 scheduled
[  508.021552] mceusb 1-1.2:1.0: send request called (size=0x21)
[  508.021598] mceusb 1-1.2:1.0: send request complete (res=0)
[  508.021963] mce_async_callback()
[  508.021981] mceusb 1-1.2:1.0: tx data: 84 b0 0c 8c 0c 84 8c 0c 8c 0c 84 8c 
0c 8c 0c 84 98 0c 98 0c 84 98 0c 8c 0c 84 8c 0c 8c 0c 81 8c 80 (length=33)
[  508.021997] mceusb 1-1.2:1.0: Raw IR data, 0 pulse/space samples
[  508.066627] mceusb 1-1.2:1.0: send request called (size=0x3)
[  508.09] mceusb 1-1.2:1.0: send request complete (res=0)
[  508.066841] mce_async_callback()
[  508.066858] mceusb 1-1.2:1.0: tx data: 9f 08 03 (length=3)
...

Open issue(s):

Testing with Pinnacle mceusb device reveals device specific (non USB 2.0 
standard) misbehavior with respect to USB TX halt.

Linux raspberrypi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l 
GNU/Linux
mceusb 1-1.2:1.0: Registered Pinnacle Systems PCTV Remote USB with mce emulator 
interface version 1
mceusb 1-1.2:1.0: 2 tx ports (0x1 cabled) and 2 rx sensors (0x1 active)

The Pinnacle device failed Linux usbtest module (modded to bind to the 
Pinnacle) test 13 with bogus halt status and -110 (-ETIMEDOUT) errors.

[ 4558.114664] usbcore: deregistering interface driver mceusb
[14956.572207] usbtest 1-1.2:1.0: mce ir device
[14956.572234] usbtest 1-1.2:1.0: full-speed {control bulk-out} tests
[14956.572363] usbcore: registered new interface driver usbtest
[15241.341143] usbtest 1-1.2:1.0: TEST 1:  write 512 bytes 1000 times
[15456.690845] usbtest 1-1.2:1.0: TEST 13:  set/clear 1000 halts
[15456.691362] usbtest 1-1.2:1.0: ep 02 bogus status: 0001 != 0
[15456.691381] usbtest 1-1.2:1.0: halts failed, iterations left 999

[37432.646344] usbcore: deregistering interface driver mceusb
[37468.447929] usbtest 1-1.2:1.0: mce ir device
[37468.447956] usbtest 1-1.2:1.0: full-speed {control bulk-out} tests
[37468.448079] usbcore: registered new interface driver usbtest
[37519.150810] usbtest 1-1.2:1.0: TEST 1:  write 512 bytes 1000 times
[37537.853493] usbtest 1-1.2:1.0: TEST 13:  set/clear 1000 halts
[37547.866871] usb 1-1.2: verify_not_halted failed, iterations left 0, status 
-110 (not 0)
[37547.866901] usbtest 1-1.2:1.0: halts failed, iterations left 999

With mceusb, upon executing usb_clear_halt() on this Pinnacle mceusb USB TX 
end-point, regardless of its halt/stall state, TX functionality silently ceases.
mce_async_callback() invocations cease, and there are no other error 
indications 

et8ek8 camera on Nokia N900: trying to understand what is going on with modes

2017-04-12 Thread Pavel Machek
Hi!

5Mpix mode does not work on N900, which is something I'd like to
understand. et8ek8_mode contains huge tables of register settings and
parameter values, but it seems that they are not really independend.

To test that theory, I started with checking values against each
other.

This is the work so far, it is neither complete nor completely working
at the moment. Perhaps someone wants to play...

Pavel

diff --git a/drivers/media/i2c/et8ek8/et8ek8_driver.c 
b/drivers/media/i2c/et8ek8/et8ek8_driver.c
index 6296f6f..ca2f648 100644
--- a/drivers/media/i2c/et8ek8/et8ek8_driver.c
+++ b/drivers/media/i2c/et8ek8/et8ek8_driver.c
@@ -798,6 +798,8 @@ static void et8ek8_update_controls(struct et8ek8_sensor 
*sensor)
u32 min, max, pixel_rate;
static const int S = 8;
 
+   printk("Updating controls for %d x %d @ %d mode -- %s\n", mode->width, 
mode->height, mode->pixel_clock, mode->name);
+
ctrl = sensor->exposure;
 
 #ifdef COMPATIBLE
@@ -820,6 +822,127 @@ static void et8ek8_update_controls(struct et8ek8_sensor 
*sensor)
__v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate, pixel_rate << S);
 }
 
+static int read_8(struct i2c_client *client, unsigned long addr)
+{
+   int val;
+   et8ek8_i2c_read_reg(client, ET8EK8_REG_8BIT, addr, );
+   return val;
+}
+
+static int read_16(struct i2c_client *client, unsigned long addr)
+{
+   return read_8(client, addr);
+}
+
+static void assert_value(struct i2c_client *client, unsigned long addr, 
unsigned long val)
+{
+   int val2 = read_8(client, addr);
+   if (val != val2)
+   printk("et8ek8: assertion check %lx / should be %lx is %lx\n", 
addr, val, val2);
+}
+
+static void assert(struct i2c_client *client, int v, char *msg)
+{
+   if (!v)
+   printk("et8ek8: assertion: %s\n", msg);
+}
+
+static void assert_eq(struct i2c_client *client, int v1, int v2, char *msg)
+{
+   if (v1 != v2)
+   printk("et8ek8: assertion: %d == %d %s\n", v1, v2, msg);
+}
+
+static void et8ek8_check(struct et8ek8_sensor *sensor)
+{
+   /*
+ 1239 4F   # CKVAR_DIV
+ 1238 02   # CKVAR_DIV[8] CKREF_DIV
+ 123B 70   # MRCK_DIV LVDSCK_DIV
+ 123A 05   # VCO_DIV SPCK_DIV
+ 121B 63   # PIC_SIZE MONI_MODE
+ 1220 85   # H_COUNT
+ 1221 00   # H_COUNT[10:8]
+ 1222 58   # V_COUNT
+ 1223 00   # V_COUNT[12:8]
+ 121D 63   # H_SIZE H_INTERMIT
+ 125D 83   # CCP_LVDS_MODE/ _/ _/ _/ _/ CCP_COMP_MODE[2-0]
+   */
+   struct et8ek8_reglist *r = sensor->current_reglist;
+   struct v4l2_subdev *subdev = >subdev;
+   struct i2c_client *client = v4l2_get_subdevdata(subdev);
+   int vco;
+   
+   printk("Mode validation:\n");
+
+   assert_value(client, 0x1220, (r->mode.width / 24) & 0xff);
+   assert_value(client, 0x1221, (r->mode.width / 24) >> 8);
+   
+   assert_value(client, 0x1222, (r->mode.height / 24) & 0xff);
+   assert_value(client, 0x1223, (r->mode.height / 24) >> 8);
+
+   {
+   int ckref_div = read_16(client, 0x1238) & 0xf;
+   int ckvar_div = ((read_16(client, 0x1238) & 0x80) >> 7) | 
(read_16(client, 0x1239) << 1);
+   int vco_div = read_16(client, 0x123A) >> 4;
+   int spck_div = read_16(client, 0x123A) & 0xf;
+   int mrck_div = read_16(client, 0x123B) >> 4;
+   int lvdsck_div = read_16(client, 0x123B) & 0xf;
+
+   vco = (r->mode.ext_clock * ckvar_div) / (ckref_div + 1);
+   printk("Vco is %d, %d %d %d\n", vco, r->mode.ext_clock, 
ckvar_div, ckref_div);
+   int ccp2 = vco / ((lvdsck_div + 1) * (vco_div + 1));
+   int spck = vco / ((spck_div + 1) * (vco_div + 1));
+
+   assert_eq(client, r->mode.pixel_clock, spck, "spck");
+   }
+
+   assert_eq(client, r->mode.max_exp, r->mode.height - 4, "max_exp");
+
+   assert(client, !(r->mode.sensor_window_width % r->mode.window_width), 
"window_width");
+   switch(r->mode.sensor_window_width / r->mode.window_width) {
+   case 1: assert_value(client, 0x121d, 0x64);
+   break;
+   case 2: assert_value(client, 0x121d, 0x63);
+   break;
+   case 3: assert_value(client, 0x121d, 0x62);
+   break;
+   default:
+   assert(client, 0, "bad window_width");
+   }
+
+   assert(client, !(r->mode.sensor_window_height % r->mode.window_height), 
"window_width");
+   switch(r->mode.sensor_window_height / r->mode.window_height) {
+   case 1: assert_value(client, 0x121b, 0x64);
+   break;
+   case 2: assert_value(client, 0x121b, 0x63);
+   break;
+   case 3: assert_value(client, 0x121b, 0x62);
+   break;
+   default:
+   assert(client, 0, "bad window_height");
+ 

[PATCH v2 2/5] media: rc: meson-ir: make use of the bitfield macros

2017-04-12 Thread Heiner Kallweit
Make use of the bitfield macros thus partially hiding the complexity
of dealing with bitfields.

The patch also includes a minor fix to REG0_RATE_MASK, so far it was
set to bit 0..10, but according to the spec it's bit 0..11.

Signed-off-by: Heiner Kallweit 
Reviewed-by: Neil Armstrong 
---
v2:
- revert change in meson_ir_set_mask
- add R-b
---
 drivers/media/rc/meson-ir.c | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index a4128d7c..3864ebe3 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -36,27 +37,24 @@
 /* only available on Meson 8b and newer */
 #define IR_DEC_REG20x20
 
-#define REG0_RATE_MASK (BIT(11) - 1)
+#define REG0_RATE_MASK GENMASK(11, 0)
 
 #define DECODE_MODE_NEC0x0
 #define DECODE_MODE_RAW0x2
 
 /* Meson 6b uses REG1 to configure the mode */
 #define REG1_MODE_MASK GENMASK(8, 7)
-#define REG1_MODE_SHIFT7
 
 /* Meson 8b / GXBB use REG2 to configure the mode */
 #define REG2_MODE_MASK GENMASK(3, 0)
-#define REG2_MODE_SHIFT0
 
-#define REG1_TIME_IV_SHIFT 16
-#define REG1_TIME_IV_MASK  ((BIT(13) - 1) << REG1_TIME_IV_SHIFT)
+#define REG1_TIME_IV_MASK  GENMASK(28, 16)
 
-#define REG1_IRQSEL_MASK   (BIT(2) | BIT(3))
-#define REG1_IRQSEL_NEC_MODE   (0 << 2)
-#define REG1_IRQSEL_RISE_FALL  (1 << 2)
-#define REG1_IRQSEL_FALL   (2 << 2)
-#define REG1_IRQSEL_RISE   (3 << 2)
+#define REG1_IRQSEL_MASK   GENMASK(3, 2)
+#define REG1_IRQSEL_NEC_MODE   0
+#define REG1_IRQSEL_RISE_FALL  1
+#define REG1_IRQSEL_FALL   2
+#define REG1_IRQSEL_RISE   3
 
 #define REG1_RESET BIT(0)
 #define REG1_ENABLEBIT(15)
@@ -91,7 +89,7 @@ static irqreturn_t meson_ir_irq(int irqno, void *dev_id)
spin_lock(>lock);
 
duration = readl(ir->reg + IR_DEC_REG1);
-   duration = (duration & REG1_TIME_IV_MASK) >> REG1_TIME_IV_SHIFT;
+   duration = FIELD_GET(REG1_TIME_IV_MASK, duration);
rawir.duration = US_TO_NS(duration * MESON_TRATE);
 
rawir.pulse = !!(readl(ir->reg + IR_DEC_STATUS) & STATUS_IR_DEC_IN);
@@ -170,16 +168,16 @@ static int meson_ir_probe(struct platform_device *pdev)
/* Set general operation mode (= raw/software decoding) */
if (of_device_is_compatible(node, "amlogic,meson6-ir"))
meson_ir_set_mask(ir, IR_DEC_REG1, REG1_MODE_MASK,
- DECODE_MODE_RAW << REG1_MODE_SHIFT);
+ FIELD_PREP(REG1_MODE_MASK, DECODE_MODE_RAW));
else
meson_ir_set_mask(ir, IR_DEC_REG2, REG2_MODE_MASK,
- DECODE_MODE_RAW << REG2_MODE_SHIFT);
+ FIELD_PREP(REG2_MODE_MASK, DECODE_MODE_RAW));
 
/* Set rate */
meson_ir_set_mask(ir, IR_DEC_REG0, REG0_RATE_MASK, MESON_TRATE - 1);
/* IRQ on rising and falling edges */
meson_ir_set_mask(ir, IR_DEC_REG1, REG1_IRQSEL_MASK,
- REG1_IRQSEL_RISE_FALL);
+ FIELD_PREP(REG1_IRQSEL_MASK, REG1_IRQSEL_RISE_FALL));
/* Enable the decoder */
meson_ir_set_mask(ir, IR_DEC_REG1, REG1_ENABLE, REG1_ENABLE);
 
-- 
2.12.2




[PATCH v2 4/5] media: rc: meson-ir: use readl_relaxed in the interrupt handler

2017-04-12 Thread Heiner Kallweit
We don't need the memory barriers here and an interrupt handler should
be as fast as possible. Therefore switch to readl_relaxed.

Signed-off-by: Heiner Kallweit 
Reviewed-by: Neil Armstrong 
---
v2:
- added R-b
---
 drivers/media/rc/meson-ir.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index cf8943d2..1c72593d 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -83,16 +83,17 @@ static void meson_ir_set_mask(struct meson_ir *ir, unsigned 
int reg,
 static irqreturn_t meson_ir_irq(int irqno, void *dev_id)
 {
struct meson_ir *ir = dev_id;
-   u32 duration;
+   u32 duration, status;
DEFINE_IR_RAW_EVENT(rawir);
 
spin_lock(>lock);
 
-   duration = readl(ir->reg + IR_DEC_REG1);
+   duration = readl_relaxed(ir->reg + IR_DEC_REG1);
duration = FIELD_GET(REG1_TIME_IV_MASK, duration);
rawir.duration = US_TO_NS(duration * MESON_TRATE);
 
-   rawir.pulse = !!(readl(ir->reg + IR_DEC_STATUS) & STATUS_IR_DEC_IN);
+   status = readl_relaxed(ir->reg + IR_DEC_STATUS);
+   rawir.pulse = !!(status & STATUS_IR_DEC_IN);
 
ir_raw_event_store_with_filter(ir->rc, );
ir_raw_event_handle(ir->rc);
-- 
2.12.2




[PATCH v2 3/5] media: rc: meson-ir: switch to managed rc device allocation / registration

2017-04-12 Thread Heiner Kallweit
Switch to the managed versions of rc_allocate_device/rc_register_device,
thus simplifying the code.

Signed-off-by: Heiner Kallweit 
Reviewed-by: Neil Armstrong 
---
v2:
- added R-b
---
 drivers/media/rc/meson-ir.c | 18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index 3864ebe3..cf8943d2 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -128,7 +128,7 @@ static int meson_ir_probe(struct platform_device *pdev)
return irq;
}
 
-   ir->rc = rc_allocate_device(RC_DRIVER_IR_RAW);
+   ir->rc = devm_rc_allocate_device(dev, RC_DRIVER_IR_RAW);
if (!ir->rc) {
dev_err(dev, "failed to allocate rc device\n");
return -ENOMEM;
@@ -140,7 +140,6 @@ static int meson_ir_probe(struct platform_device *pdev)
ir->rc->input_id.bustype = BUS_HOST;
map_name = of_get_property(node, "linux,rc-map-name", NULL);
ir->rc->map_name = map_name ? map_name : RC_MAP_EMPTY;
-   ir->rc->dev.parent = dev;
ir->rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
ir->rc->rx_resolution = US_TO_NS(MESON_TRATE);
ir->rc->timeout = MS_TO_NS(200);
@@ -149,16 +148,16 @@ static int meson_ir_probe(struct platform_device *pdev)
spin_lock_init(>lock);
platform_set_drvdata(pdev, ir);
 
-   ret = rc_register_device(ir->rc);
+   ret = devm_rc_register_device(dev, ir->rc);
if (ret) {
dev_err(dev, "failed to register rc device\n");
-   goto out_free;
+   return ret;
}
 
ret = devm_request_irq(dev, irq, meson_ir_irq, 0, "ir-meson", ir);
if (ret) {
dev_err(dev, "failed to request irq\n");
-   goto out_unreg;
+   return ret;
}
 
/* Reset the decoder */
@@ -184,13 +183,6 @@ static int meson_ir_probe(struct platform_device *pdev)
dev_info(dev, "receiver initialized\n");
 
return 0;
-out_unreg:
-   rc_unregister_device(ir->rc);
-   ir->rc = NULL;
-out_free:
-   rc_free_device(ir->rc);
-
-   return ret;
 }
 
 static int meson_ir_remove(struct platform_device *pdev)
@@ -203,8 +195,6 @@ static int meson_ir_remove(struct platform_device *pdev)
meson_ir_set_mask(ir, IR_DEC_REG1, REG1_ENABLE, 0);
spin_unlock_irqrestore(>lock, flags);
 
-   rc_unregister_device(ir->rc);
-
return 0;
 }
 
-- 
2.12.2




[PATCH v2 1/5] media: rc: meson-ir: remove irq from struct meson_ir

2017-04-12 Thread Heiner Kallweit
The irq number is used in the probe function only, therefore just use
a local variable.

Signed-off-by: Heiner Kallweit 
---
v2:
- no changes
---
 drivers/media/rc/meson-ir.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index 5576dbd6..a4128d7c 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -68,7 +68,6 @@
 struct meson_ir {
void __iomem*reg;
struct rc_dev   *rc;
-   int irq;
spinlock_t  lock;
 };
 
@@ -112,7 +111,7 @@ static int meson_ir_probe(struct platform_device *pdev)
struct resource *res;
const char *map_name;
struct meson_ir *ir;
-   int ret;
+   int irq, ret;
 
ir = devm_kzalloc(dev, sizeof(struct meson_ir), GFP_KERNEL);
if (!ir)
@@ -125,10 +124,10 @@ static int meson_ir_probe(struct platform_device *pdev)
return PTR_ERR(ir->reg);
}
 
-   ir->irq = platform_get_irq(pdev, 0);
-   if (ir->irq < 0) {
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0) {
dev_err(dev, "no irq resource\n");
-   return ir->irq;
+   return irq;
}
 
ir->rc = rc_allocate_device(RC_DRIVER_IR_RAW);
@@ -158,7 +157,7 @@ static int meson_ir_probe(struct platform_device *pdev)
goto out_free;
}
 
-   ret = devm_request_irq(dev, ir->irq, meson_ir_irq, 0, "ir-meson", ir);
+   ret = devm_request_irq(dev, irq, meson_ir_irq, 0, "ir-meson", ir);
if (ret) {
dev_err(dev, "failed to request irq\n");
goto out_unreg;
-- 
2.12.2




[PATCH v2 5/5] media: rc: meson-ir: change irq name to to of node name

2017-04-12 Thread Heiner Kallweit
Switch the interrupt description to the default which is the of node
name. This is more in line with the interrupt descriptions in
other meson drivers.

Signed-off-by: Heiner Kallweit 
---
v2:
- no changes
---
 drivers/media/rc/meson-ir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index 1c72593d..1ece3c04 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -155,7 +155,7 @@ static int meson_ir_probe(struct platform_device *pdev)
return ret;
}
 
-   ret = devm_request_irq(dev, irq, meson_ir_irq, 0, "ir-meson", ir);
+   ret = devm_request_irq(dev, irq, meson_ir_irq, 0, NULL, ir);
if (ret) {
dev_err(dev, "failed to request irq\n");
return ret;
-- 
2.12.2




[PATCH v2 0/5] media: rc: meson-ir: series with smaller improvements

2017-04-12 Thread Heiner Kallweit
This series includes smaller improvements for the meson-ir driver.
Tested on a Odroid C2.

v2:
- minor change to patch 2
- added Reviewed-by to patch 2, 3, 4

Heiner Kallweit (5):
  media: rc: meson-ir: remove irq from struct meson_ir
  media: rc: meson-ir: make use of the bitfield macros
  media: rc: meson-ir: switch to managed rc device allocation / registration
  media: rc: meson-ir: use readl_relaxed in the interrupt handler
  media: rc: meson-ir: change irq name to to of node name

 drivers/media/rc/meson-ir.c | 64 ++---
 1 file changed, 26 insertions(+), 38 deletions(-)

-- 
2.12.2



Re: [PATCH v3 00/13] stv0367/ddbridge: support CTv6/FlexCT hardware

2017-04-12 Thread Daniel Scheller
Am Wed, 29 Mar 2017 18:43:00 +0200
schrieb Daniel Scheller :

> From: Daniel Scheller 
> 
> Third iteration of the DD CineCTv6/FlexCT support patches with mostly
> all things cleaned up that popped up so far. Obsoletes V1 and V2
> series.
> 
> These patches enhance the functionality of dvb-frontends/stv0367 to
> work with Digital Devices hardware driven by the ST STV0367
> demodulator chip and adds probe & attach bits to ddbridge to make use
> of them, effectively enabling full support for CineCTv6 PCIe bridges
> and (older) DuoFlex CT addon modules.

Since V1 was sent over five weeks ago: Ping? Anyone? I'd really like to
get this upstreamed.

Regards,
Daniel


[PATCH 14/14] atomisp: remove UDS kernel code

2017-04-12 Thread Alan Cox
UDS is another layer which actually boils down to some trivial assignments so
remove it so inline the code.

Signed-off-by: Alan Cox 
---
 .../ia_css_isp_params.c|   12 ---
 .../ia_css_isp_params.c|   12 ---
 .../ia_css_isp_params.c|   12 ---
 .../isp/kernels/uds/uds_1.0/ia_css_uds.host.c  |   35 
 .../isp/kernels/uds/uds_1.0/ia_css_uds.host.h  |   33 ---
 .../css2400/runtime/debug/src/ia_css_debug.c   |2 +
 .../atomisp/pci/atomisp2/css2400/sh_css_params.c   |2 +
 7 files changed, 23 insertions(+), 85 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/uds/uds_1.0/ia_css_uds.host.c
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/uds/uds_1.0/ia_css_uds.host.h

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c
index 49a5cdf..d418e76 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c
@@ -43,7 +43,7 @@
 #include "isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.h"
 #include "isp/kernels/sdis/sdis_2/ia_css_sdis2.host.h"
 #include "isp/kernels/tnr/tnr_1.0/ia_css_tnr.host.h"
-#include "isp/kernels/uds/uds_1.0/ia_css_uds.host.h"
+#include "isp/kernels/uds/uds_1.0/ia_css_uds_param.h"
 #include "isp/kernels/wb/wb_1.0/ia_css_wb.host.h"
 #include "isp/kernels/xnr/xnr_1.0/ia_css_xnr.host.h"
 #include "isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.h"
@@ -719,12 +719,14 @@ ia_css_process_uds(
unsigned offset = 
stage->binary->info->mem_offsets.offsets.param->dmem.uds.offset;
 
if (size) {
+   struct sh_css_sp_uds_params *p;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, 
"ia_css_process_uds() enter:\n");
 
-   ia_css_uds_encode((struct sh_css_sp_uds_params *)
-   
>binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-   >uds_config,
-size);
+   p = (struct sh_css_sp_uds_params *)
+   
>binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset];
+   p->crop_pos = params->uds_config.crop_pos;
+   p->uds = params->uds_config.uds;
+
params->isp_params_changed = true;

params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = 
true;
 
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_params.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_params.c
index 41b8a5f..11e4463 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_params.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_params.c
@@ -44,7 +44,7 @@
 #include "isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.h"
 #include "isp/kernels/sdis/sdis_2/ia_css_sdis2.host.h"
 #include "isp/kernels/tnr/tnr_1.0/ia_css_tnr.host.h"
-#include "isp/kernels/uds/uds_1.0/ia_css_uds.host.h"
+#include "isp/kernels/uds/uds_1.0/ia_css_uds_param.h"
 #include "isp/kernels/wb/wb_1.0/ia_css_wb.host.h"
 #include "isp/kernels/xnr/xnr_1.0/ia_css_xnr.host.h"
 #include "isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.h"
@@ -718,12 +718,14 @@ ia_css_process_uds(
unsigned offset = 
stage->binary->info->mem_offsets.offsets.param->dmem.uds.offset;
 
if (size) {
+   struct sh_css_sp_uds_params *p;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, 
"ia_css_process_uds() enter:\n");
 
-   ia_css_uds_encode((struct sh_css_sp_uds_params *)
-   
>binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-   >uds_config,
-size);
+   p = (struct sh_css_sp_uds_params *)
+   
>binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset];
+   p->crop_pos = params->uds_config.crop_pos;
+   p->uds = params->uds_config.uds;
+

[PATCH 13/14] atomisp: remove xnr3_0_5 and xnr3_0_11

2017-04-12 Thread Alan Cox
These are not used in the driver so can go away.

Signed-off-by: Alan Cox 
---
 .../staging/media/atomisp/pci/atomisp2/Makefile|4 -
 .../kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11.host.c  |  155 
 .../kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11.host.h  |   58 ---
 .../kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11_param.h |   50 --
 .../kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11_types.h |   33 
 .../kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5.host.c|  154 
 .../kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5.host.h|   59 
 .../kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5_param.h   |   50 --
 .../kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5_types.h   |   33 
 9 files changed, 596 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11.host.c
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11.host.h
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11_param.h
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11_types.h
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5.host.c
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5.host.h
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5_param.h
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5_types.h

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/Makefile 
b/drivers/staging/media/atomisp/pci/atomisp2/Makefile
index 8780914..f6d01c2 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/Makefile
+++ b/drivers/staging/media/atomisp/pci/atomisp2/Makefile
@@ -82,9 +82,7 @@ atomisp-objs += \
css2400/isp/kernels/cnr/cnr_1.0/ia_css_cnr.host.o \
css2400/isp/kernels/xnr/xnr_1.0/ia_css_xnr.host.o \
css2400/isp/kernels/xnr/xnr_1.0/ia_css_xnr_table.host.o \
-   css2400/isp/kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5.host.o \
css2400/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.o \
-   css2400/isp/kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11.host.o \
css2400/isp/kernels/de/de_1.0/ia_css_de.host.o \
css2400/isp/kernels/de/de_2/ia_css_de2.host.o \
css2400/isp/kernels/gc/gc_2/ia_css_gc2.host.o \
@@ -328,8 +326,6 @@ INCLUDES += \
-I$(atomisp)/css2400/isp/kernels/xnr/ \
-I$(atomisp)/css2400/isp/kernels/xnr/xnr_1.0/ \
-I$(atomisp)/css2400/isp/kernels/xnr/xnr_3.0/ \
-   -I$(atomisp)/css2400/isp/kernels/xnr/xnr3_0_11 \
-   -I$(atomisp)/css2400/isp/kernels/xnr/xnr3_0_5/ \
-I$(atomisp)/css2400/isp/kernels/ynr/ \
-I$(atomisp)/css2400/isp/kernels/ynr/ynr_1.0/ \
-I$(atomisp)/css2400/isp/kernels/ynr/ynr_2/ \
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11.host.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11.host.c
deleted file mode 100644
index 7e86bc8..000
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/xnr/xnr3_0_11/ia_css_xnr3_0_11.host.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-#include "type_support.h"
-#include "math_support.h"
-#include "sh_css_defs.h"
-#include "assert_support.h"
-#include "ia_css_xnr3_0_11.host.h"
-
-/*
- * XNR 3.0.11 division look-up table
- */
-#define XNR3_0_11_LOOK_UP_TABLE_POINTS 16
-
-static const int16_t x[XNR3_0_11_LOOK_UP_TABLE_POINTS] = {
-512, 637, 782, 952, 1147, 1372, 1627, 1917, 2242,
-2597, 2992, 3427, 3907, 4432, 5007, 5632};
-
-static const int16_t a[XNR3_0_11_LOOK_UP_TABLE_POINTS] = {
--6587, -4309, -2886, -1970, -1362, -7710, -5508,
--4008, -2931, -2219, -1676, -1280, -999, -769, -616, 0};
-
-static const int16_t b[XNR3_0_11_LOOK_UP_TABLE_POINTS] = {
-4096, 3292, 2682, 2203, 1828, 1529, 1289, 1094,
-935, 808, 701, 612, 537, 473, 419, 372};
-
-static const int16_t c[XNR3_0_11_LOOK_UP_TABLE_POINTS] = {
-1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-
-/*
- * Default kernel parameters (weights). In general, default is bypass mode or 
as close
- * to the ineffective values as possible. Due to the 

[PATCH 12/14] atomisp: remove fixedbds kernel code

2017-04-12 Thread Alan Cox
This is a whole pile of code that wraps a single assignment. Remove it and
put the assignment in the caller. Once we have the kernels sorted we should
revisit these and remove all the pointless 1 item structs that go with it.

Signed-off-by: Alan Cox 
---
 .../ia_css_isp_params.c|   11 +++--
 .../ia_css_isp_params.c|   11 +++--
 .../ia_css_isp_params.c|   11 +++--
 .../fixedbds/fixedbds_1.0/ia_css_fixedbds.host.c   |   47 
 .../fixedbds/fixedbds_1.0/ia_css_fixedbds.host.h   |   37 
 .../atomisp/pci/atomisp2/css2400/sh_css_params.c   |2 -
 6 files changed, 19 insertions(+), 100 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds.host.c
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds.host.h

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c
index 3246d99..49a5cdf 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c
@@ -28,7 +28,7 @@
 #include "isp/kernels/de/de_1.0/ia_css_de.host.h"
 #include "isp/kernels/de/de_2/ia_css_de2.host.h"
 #include "isp/kernels/dp/dp_1.0/ia_css_dp.host.h"
-#include "isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds.host.h"
+#include "isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds_param.h"
 #include "isp/kernels/fpn/fpn_1.0/ia_css_fpn.host.h"
 #include "isp/kernels/gc/gc_1.0/ia_css_gc.host.h"
 #include "isp/kernels/gc/gc_2/ia_css_gc2.host.h"
@@ -924,12 +924,13 @@ ia_css_process_bds(
unsigned offset = 
stage->binary->info->mem_offsets.offsets.param->dmem.bds.offset;
 
if (size) {
+   struct sh_css_isp_bds_params *p;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, 
"ia_css_process_bds() enter:\n");
 
-   ia_css_bds_encode((struct sh_css_isp_bds_params *)
-   
>binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-   >bds_config,
-size);
+   p = (struct sh_css_isp_bds_params *)
+   
>binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset];
+   p->baf_strength = params->bds_config.strength;
+
params->isp_params_changed = true;

params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = 
true;
 
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_params.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_params.c
index 4c79a31..41b8a5f 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_params.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_params.c
@@ -29,7 +29,7 @@
 #include "isp/kernels/de/de_1.0/ia_css_de.host.h"
 #include "isp/kernels/de/de_2/ia_css_de2.host.h"
 #include "isp/kernels/dp/dp_1.0/ia_css_dp.host.h"
-#include "isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds.host.h"
+#include "isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds_param.h"
 #include "isp/kernels/fpn/fpn_1.0/ia_css_fpn.host.h"
 #include "isp/kernels/gc/gc_1.0/ia_css_gc.host.h"
 #include "isp/kernels/gc/gc_2/ia_css_gc2.host.h"
@@ -923,12 +923,13 @@ ia_css_process_bds(
unsigned offset = 
stage->binary->info->mem_offsets.offsets.param->dmem.bds.offset;
 
if (size) {
+   struct sh_css_isp_bds_params *p;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, 
"ia_css_process_bds() enter:\n");
 
-   ia_css_bds_encode((struct sh_css_isp_bds_params *)
-   
>binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-   >bds_config,
-size);
+   p = (struct sh_css_isp_bds_params *)
+   
>binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset];
+   p->baf_strength = params->bds_config.strength;
+

[PATCH 11/14] atomisp: remove satm kernel

2017-04-12 Thread Alan Cox
This isn't used so it can go in the bitbucket.

Signed-off-by: Alan Cox 
---
 .../staging/media/atomisp/pci/atomisp2/Makefile|1 -
 .../css2400/isp/kernels/satm/ia_css_satm.host.c|   27 ---
 .../css2400/isp/kernels/satm/ia_css_satm.host.h|   29 -
 .../css2400/isp/kernels/satm/ia_css_satm_param.h   |   30 -
 .../css2400/isp/kernels/satm/ia_css_satm_types.h   |   35 
 5 files changed, 122 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm.host.c
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm.host.h
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm_param.h
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm_types.h

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/Makefile 
b/drivers/staging/media/atomisp/pci/atomisp2/Makefile
index ab10fc0..8780914 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/Makefile
+++ b/drivers/staging/media/atomisp/pci/atomisp2/Makefile
@@ -80,7 +80,6 @@ atomisp-objs += \
css2400/isp/kernels/sdis/sdis_2/ia_css_sdis2.host.o \
css2400/isp/kernels/cnr/cnr_2/ia_css_cnr2.host.o \
css2400/isp/kernels/cnr/cnr_1.0/ia_css_cnr.host.o \
-   css2400/isp/kernels/satm/ia_css_satm.host.o \
css2400/isp/kernels/xnr/xnr_1.0/ia_css_xnr.host.o \
css2400/isp/kernels/xnr/xnr_1.0/ia_css_xnr_table.host.o \
css2400/isp/kernels/xnr/xnr3_0_5/ia_css_xnr3_0_5.host.o \
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm.host.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm.host.c
deleted file mode 100644
index d35194b..000
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm.host.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-#include "ia_css_satm.host.h"
-
-
-void
-ia_css_satm_init_config(
-   struct sh_css_isp_satm_params *to,
-   const struct ia_css_satm_config *from,
-   unsigned size)
-{
-   (void) size;
-
-   to->params.test_satm = from->params.test_satm;
-}
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm.host.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm.host.h
deleted file mode 100644
index 807b716..000
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm.host.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-#ifndef __IA_CSS_SATM_HOST_H
-#define __IA_CSS_SATM_HOST_H
-
-#include "ia_css_satm_param.h"
-#include "ia_css_satm_types.h"
-
-extern const struct ia_css_satm_config default_satm_config;
-
-void
-ia_css_satm_init_config(
-   struct sh_css_isp_satm_params *to,
-   const struct ia_css_satm_config *from,
-   unsigned size);
-
-#endif /* __IA_CSS_SATM_HOST_H */
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm_param.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm_param.h
deleted file mode 100644
index 062f79aa4..000
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/satm/ia_css_satm_param.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 

[PATCH 09/14] atomisp: remove sh_css_malloc indirections where we can

2017-04-12 Thread Alan Cox
Where we know the buffer size is reasonably constrained we can just use kmalloc,
and where it will be large vmalloc. This still leaves a pile in the middle.

Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   92 ++--
 .../atomisp/pci/atomisp2/css2400/sh_css_firmware.c |   29 +++---
 .../pci/atomisp2/css2400/sh_css_host_data.c|8 +-
 .../pci/atomisp2/css2400/sh_css_param_shading.c|8 +-
 4 files changed, 72 insertions(+), 65 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 30f7196..2359449 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -2492,19 +2492,19 @@ create_pipe(enum ia_css_pipe_mode mode,
return IA_CSS_ERR_INVALID_ARGUMENTS;
}
 
-   me = sh_css_malloc(sizeof(*me));
+   me = kmalloc(sizeof(*me), GFP_KERNEL);
if (!me)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
 
err = init_pipe_defaults(mode, me, copy_pipe);
if (err != IA_CSS_SUCCESS) {
-   sh_css_free(me);
+   kfree(me);
return err;
}
 
err = pipe_generate_pipe_num(me, &(me->pipe_num));
if (err != IA_CSS_SUCCESS) {
-   sh_css_free(me);
+   kfree(me);
return err;
}
 
@@ -2631,7 +2631,7 @@ ia_css_pipe_destroy(struct ia_css_pipe *pipe)
if (pipe->config.acc_extension) {
ia_css_pipe_unload_extension(pipe, pipe->config.acc_extension);
}
-   sh_css_free(pipe);
+   kfree(pipe);
IA_CSS_LEAVE("err = %d", err);
return err;
 }
@@ -5764,14 +5764,14 @@ static enum ia_css_err load_video_binaries(struct 
ia_css_pipe *pipe)
if (err != IA_CSS_SUCCESS)
return err;
mycs->num_yuv_scaler = cas_scaler_descr.num_stage;
-   mycs->yuv_scaler_binary = 
sh_css_calloc(cas_scaler_descr.num_stage,
-   sizeof(struct ia_css_binary));
+   mycs->yuv_scaler_binary = kzalloc(cas_scaler_descr.num_stage *
+   sizeof(struct ia_css_binary), GFP_KERNEL);
if (mycs->yuv_scaler_binary == NULL) {
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
return err;
}
-   mycs->is_output_stage = 
sh_css_calloc(cas_scaler_descr.num_stage,
-   sizeof(bool));
+   mycs->is_output_stage = kzalloc(cas_scaler_descr.num_stage
+   * sizeof(bool), GFP_KERNEL);
if (mycs->is_output_stage == NULL) {
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
return err;
@@ -5787,7 +5787,7 @@ static enum ia_css_err load_video_binaries(struct 
ia_css_pipe *pipe)
err = ia_css_binary_find(_scaler_descr,
>yuv_scaler_binary[i]);
if (err != IA_CSS_SUCCESS) {
-   sh_css_free(mycs->is_output_stage);
+   kfree(mycs->is_output_stage);
mycs->is_output_stage = NULL;
return err;
}
@@ -6008,9 +6008,9 @@ unload_video_binaries(struct ia_css_pipe *pipe)
for (i = 0; i < pipe->pipe_settings.video.num_yuv_scaler; i++)

ia_css_binary_unload(>pipe_settings.video.yuv_scaler_binary[i]);
 
-   sh_css_free(pipe->pipe_settings.video.is_output_stage);
+   kfree(pipe->pipe_settings.video.is_output_stage);
pipe->pipe_settings.video.is_output_stage = NULL;
-   sh_css_free(pipe->pipe_settings.video.yuv_scaler_binary);
+   kfree(pipe->pipe_settings.video.yuv_scaler_binary);
pipe->pipe_settings.video.yuv_scaler_binary = NULL;
 
IA_CSS_LEAVE_ERR_PRIVATE(IA_CSS_SUCCESS);
@@ -6418,15 +6418,15 @@ static enum ia_css_err load_primary_binaries(
return err;
}
mycs->num_yuv_scaler = cas_scaler_descr.num_stage;
-   mycs->yuv_scaler_binary = 
sh_css_calloc(cas_scaler_descr.num_stage,
-   sizeof(struct ia_css_binary));
+   mycs->yuv_scaler_binary = kzalloc(cas_scaler_descr.num_stage *
+   sizeof(struct ia_css_binary), GFP_KERNEL);
if (mycs->yuv_scaler_binary == NULL) {
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
IA_CSS_LEAVE_ERR_PRIVATE(err);
return err;
}
-   mycs->is_output_stage = 
sh_css_calloc(cas_scaler_descr.num_stage,
-   sizeof(bool));
+   mycs->is_output_stage = 

[PATCH 06/14] atomisp: remove most of the uses of atomisp_kernel_malloc

2017-04-12 Thread Alan Cox
They can be replaced by kmalloc. There are a few that do need to pick kmalloc
or vmalloc. Those we leave for the moment.

Signed-off-by: Alan Cox 
---
 .../atomisp/pci/atomisp2/atomisp_compat_css20.c|4 --
 .../media/atomisp/pci/atomisp2/hmm/hmm_bo.c|   34 ++--
 .../atomisp/pci/atomisp2/hmm/hmm_dynamic_pool.c|8 ++---
 .../atomisp/pci/atomisp2/hmm/hmm_reserved_pool.c   |   14 
 4 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
index 2e20a81..6586842 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
@@ -1669,11 +1669,7 @@ int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device 
*asd)
 
 int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd)
 {
-#ifndef ISP2401
-   int i; /* Coverity CID 298003 - index var must be signed */
-#else
int i;
-#endif
 
/* We allocate the cpu-side buffer used for communication with user
 * space */
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c 
b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
index a51a27b..11162f5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
@@ -725,8 +725,8 @@ static int alloc_private_pages(struct hmm_buffer_object *bo,
 
pgnr = bo->pgnr;
 
-   bo->page_obj = atomisp_kernel_malloc(
-   sizeof(struct hmm_page_object) * pgnr);
+   bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * pgnr,
+   GFP_KERNEL);
if (unlikely(!bo->page_obj)) {
dev_err(atomisp_dev, "out of memory for bo->page_obj\n");
return -ENOMEM;
@@ -860,7 +860,7 @@ static int alloc_private_pages(struct hmm_buffer_object *bo,
alloc_pgnr = i;
free_private_bo_pages(bo, dypool, repool, alloc_pgnr);
 
-   atomisp_kernel_free(bo->page_obj);
+   kfree(bo->page_obj);
 
return -ENOMEM;
 }
@@ -871,7 +871,7 @@ static void free_private_pages(struct hmm_buffer_object *bo,
 {
free_private_bo_pages(bo, dypool, repool, bo->pgnr);
 
-   atomisp_kernel_free(bo->page_obj);
+   kfree(bo->page_obj);
 }
 
 /*
@@ -990,17 +990,17 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
struct vm_area_struct *vma;
struct page **pages;
 
-   pages = atomisp_kernel_malloc(sizeof(struct page *) * bo->pgnr);
+   pages = kmalloc(sizeof(struct page *) * bo->pgnr, GFP_KERNEL);
if (unlikely(!pages)) {
dev_err(atomisp_dev, "out of memory for pages...\n");
return -ENOMEM;
}
 
-   bo->page_obj = atomisp_kernel_malloc(
-   sizeof(struct hmm_page_object) * bo->pgnr);
+   bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * bo->pgnr,
+   GFP_KERNEL);
if (unlikely(!bo->page_obj)) {
dev_err(atomisp_dev, "out of memory for bo->page_obj...\n");
-   atomisp_kernel_free(pages);
+   kfree(pages);
return -ENOMEM;
}
 
@@ -1010,8 +1010,8 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
up_read(>mm->mmap_sem);
if (vma == NULL) {
dev_err(atomisp_dev, "find_vma failed\n");
-   atomisp_kernel_free(bo->page_obj);
-   atomisp_kernel_free(pages);
+   kfree(bo->page_obj);
+   kfree(pages);
mutex_lock(>mutex);
return -EFAULT;
}
@@ -1051,15 +1051,15 @@ static int alloc_user_pages(struct hmm_buffer_object 
*bo,
bo->page_obj[i].type = HMM_PAGE_TYPE_GENERAL;
}
hmm_mem_stat.usr_size += bo->pgnr;
-   atomisp_kernel_free(pages);
+   kfree(pages);
 
return 0;
 
 out_of_mem:
for (i = 0; i < page_nr; i++)
put_page(pages[i]);
-   atomisp_kernel_free(pages);
-   atomisp_kernel_free(bo->page_obj);
+   kfree(pages);
+   kfree(bo->page_obj);
 
return -ENOMEM;
 }
@@ -1072,7 +1072,7 @@ static void free_user_pages(struct hmm_buffer_object *bo)
put_page(bo->page_obj[i].page);
hmm_mem_stat.usr_size -= bo->pgnr;
 
-   atomisp_kernel_free(bo->page_obj);
+   kfree(bo->page_obj);
 }
 
 /*
@@ -1363,7 +1363,7 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool 
cached)
bo->status &= ~(HMM_BO_VMAPED | HMM_BO_VMAPED_CACHED);
}
 
-   pages = atomisp_kernel_malloc(sizeof(*pages) * bo->pgnr);
+   pages = kmalloc(sizeof(*pages) * bo->pgnr, GFP_KERNEL);
if (unlikely(!pages)) {
mutex_unlock(>mutex);
dev_err(atomisp_dev, "out of memory 

[PATCH 10/14] atomisp: remove contiguous handling

2017-04-12 Thread Alan Cox
The base hmm MMU code doesn't support contiguous allocations (they BUG), so
remove support from them from the higher levels of the heirarchy.

We still need to unwind all these layers but it turns out that some of the init
order stuff is rather sensitive and the simple cleanup breaks everything

Signed-off-by: Alan Cox 
---
 .../pci/atomisp2/css2400/ia_css_memory_access.c|   31 ++--
 .../atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.c |   11 ---
 .../atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.h |3 --
 .../media/atomisp/pci/atomisp2/hrt/memory_access.c |   31 
 4 files changed, 15 insertions(+), 61 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_memory_access.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_memory_access.c
index 8d559aa..1f6ae20 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_memory_access.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_memory_access.c
@@ -31,31 +31,18 @@ mmgr_malloc(const size_t size)
 hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attrs)
 {
uint16_t masked_attrs = attrs & MMGR_ATTRIBUTE_MASK;
+   WARN_ON(attrs & MMGR_ATTRIBUTE_CONTIGUOUS);
 
if (masked_attrs & MMGR_ATTRIBUTE_CLEARED) {
-   if (masked_attrs & MMGR_ATTRIBUTE_CACHED) {
-   if (masked_attrs & MMGR_ATTRIBUTE_CONTIGUOUS)
-   return (ia_css_ptr) 
hrt_isp_css_mm_calloc_contiguous(size);
-   else
-   return (ia_css_ptr) 
hrt_isp_css_mm_calloc_cached(size);
-   } else {
-   if (masked_attrs & MMGR_ATTRIBUTE_CONTIGUOUS)
-   return (ia_css_ptr) 
hrt_isp_css_mm_calloc_contiguous(size);
-   else
-   return (ia_css_ptr) hrt_isp_css_mm_calloc(size);
-   }
+   if (masked_attrs & MMGR_ATTRIBUTE_CACHED)
+   return (ia_css_ptr) hrt_isp_css_mm_calloc_cached(size);
+   else
+   return (ia_css_ptr) hrt_isp_css_mm_calloc(size);
} else {
-   if (masked_attrs & MMGR_ATTRIBUTE_CACHED) {
-   if (masked_attrs & MMGR_ATTRIBUTE_CONTIGUOUS)
-   return (ia_css_ptr) 
hrt_isp_css_mm_alloc_contiguous(size);
-   else
-   return (ia_css_ptr) 
hrt_isp_css_mm_alloc_cached(size);
-   } else {
-   if (masked_attrs & MMGR_ATTRIBUTE_CONTIGUOUS)
-   return (ia_css_ptr) 
hrt_isp_css_mm_alloc_contiguous(size);
-   else
-   return (ia_css_ptr) hrt_isp_css_mm_alloc(size);
-   }
+   if (masked_attrs & MMGR_ATTRIBUTE_CACHED)
+   return (ia_css_ptr) hrt_isp_css_mm_alloc_cached(size);
+   else
+   return (ia_css_ptr) hrt_isp_css_mm_alloc(size);
}
 }
 
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.c 
b/drivers/staging/media/atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.c
index 9f8267a..78b4709 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.c
@@ -180,14 +180,3 @@ phys_addr_t hrt_isp_css_virt_to_phys(ia_css_ptr virt_addr)
return hmm_virt_to_phys(virt_addr);
 }
 
-ia_css_ptr hrt_isp_css_mm_alloc_contiguous(size_t bytes)
-{
-   BUG_ON(false);
-   return 0;
-}
-ia_css_ptr hrt_isp_css_mm_calloc_contiguous(size_t bytes)
-{
-   BUG_ON(false);
-   return 0;
-}
-
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.h 
b/drivers/staging/media/atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.h
index 41c6d14..4783206 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hrt/hive_isp_css_mm_hrt.h
@@ -81,8 +81,5 @@ int hrt_isp_css_mm_store_int(ia_css_ptr virt_addr, int data);
the display driver on  the FPGA system */
 phys_addr_t hrt_isp_css_virt_to_phys(ia_css_ptr virt_addr);
 
-ia_css_ptr hrt_isp_css_mm_alloc_contiguous(size_t bytes);
-ia_css_ptr hrt_isp_css_mm_calloc_contiguous(size_t bytes);
-
 void hrt_isp_css_mm_clear(void);
 #endif /* _hive_isp_css_mm_hrt_h_ */
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hrt/memory_access.c 
b/drivers/staging/media/atomisp/pci/atomisp2/hrt/memory_access.c
index dcc4c91..7694ee4 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hrt/memory_access.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hrt/memory_access.c
@@ -60,42 +60,23 @@ ia_css_ptr mmgr_alloc_attr(const size_t size, const 
uint16_t attribute)
 
assert(page_table_base_address != 

[PATCH 08/14] atomisp: remove indirection from sh_css_malloc

2017-04-12 Thread Alan Cox
We have one hard coded set of behaviour so unpick the indirection and function
pointers. This isn't the whole story. A lot of the callers are known sizes and
use cases so we can switch them directly to kmalloc later on.

Signed-off-by: Alan Cox 
---
 .../atomisp/pci/atomisp2/atomisp_compat_css20.c|3 -
 .../atomisp/pci/atomisp2/css2400/ia_css_env.h  |   19 ---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   52 +---
 3 files changed, 25 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
index 6586842..b830b24 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
@@ -923,9 +923,6 @@ int atomisp_css_load_firmware(struct atomisp_device *isp)
isp->css_env.isp_css_fw.data = (void *)isp->firmware->data;
isp->css_env.isp_css_fw.bytes = isp->firmware->size;
 
-   isp->css_env.isp_css_env.cpu_mem_env.alloc = atomisp_kernel_zalloc;
-   isp->css_env.isp_css_env.cpu_mem_env.free = atomisp_kernel_free;
-
isp->css_env.isp_css_env.hw_access_env.store_8 =
atomisp_css2_hw_store_8;
isp->css_env.isp_css_env.hw_access_env.store_16 =
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_env.h 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_env.h
index 4d54aea..1ae9daf 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_env.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_env.h
@@ -39,25 +39,8 @@ enum ia_css_mem_attr {
  *  This is never expected to allocate more than one page of memory (4K bytes).
  */
 struct ia_css_cpu_mem_env {
-   void * (*alloc)(size_t bytes, bool zero_mem);
-   /**< Allocation function with boolean argument to indicate whether
-the allocated memory should be zeroed out or not, true (or 1)
-meaning the memory given to CSS must be zeroed */
-   void (*free)(void *ptr);
-   /**< Corresponding free function. The function must also accept
-a NULL argument, similar to C89 free(). */
void (*flush)(struct ia_css_acc_fw *fw);
/**< Flush function to flush the cache for given accelerator. */
-#ifdef ISP2401
-
-   #if !defined(__SVOS__)
-   /* a set of matching functions with additional debug params */
-   void * (*alloc_ex)(size_t bytes, bool zero_mem, const char 
*caller_func, int caller_line);
-   /**< same as alloc above, only with additional debug parameters */
-   void (*free_ex)(void *ptr, const char *caller_func, int caller_line);
-   /**< same as free above, only with additional debug parameters */
-   #endif
-#endif
 };
 
 /** Environment with function pointers to access the CSS hardware. This 
includes
@@ -103,7 +86,7 @@ struct ia_css_print_env {
  *  Windows and several simulation environments.
  */
 struct ia_css_env {
-   struct ia_css_cpu_mem_env   cpu_mem_env;   /**< local malloc and free. 
*/
+   struct ia_css_cpu_mem_env   cpu_mem_env;   /**< local flush. */
struct ia_css_hw_access_env hw_access_env; /**< CSS HW access functions 
*/
struct ia_css_print_env print_env; /**< Message printing env. */
 };
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index aa19419..30f7196 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -13,6 +13,10 @@
  */
 
 /*! \file */
+#include 
+#include 
+#include 
+
 #include "ia_css.h"
 #include "sh_css_hrt.h"/* only for file 2 MIPI */
 #include "ia_css_buffer.h"
@@ -1679,15 +1683,8 @@ ia_css_load_firmware(const struct ia_css_env *env,
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_load_firmware() 
enter\n");
 
/* make sure we initialize my_css */
-   if ((my_css.malloc != env->cpu_mem_env.alloc) ||
-   (my_css.free != env->cpu_mem_env.free) ||
-   (my_css.flush != env->cpu_mem_env.flush)
-   )
-   {
+   if (my_css.flush != env->cpu_mem_env.flush) {
ia_css_reset_defaults(_css);
-
-   my_css.malloc = env->cpu_mem_env.alloc;
-   my_css.free = env->cpu_mem_env.free;
my_css.flush = env->cpu_mem_env.flush;
}
 
@@ -1715,8 +1712,6 @@ ia_css_init(const struct ia_css_env *env,
ia_css_blctrl_cfg blctrl_cfg;
 #endif
 
-   void *(*malloc_func)(size_t size, bool zero_mem);
-   void (*free_func)(void *ptr);
void (*flush_func)(struct ia_css_acc_fw *fw);
hrt_data select, enable;
 
@@ -1765,8 +1760,6 @@ ia_css_init(const struct ia_css_env *env,
 

[PATCH 07/14] atomisp: unwrap the _ex malloc/free functions

2017-04-12 Thread Alan Cox
We are not using these for debugging or debug logging so remove the defines,
trim and rename the functions.

Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   15 +++
 .../atomisp/pci/atomisp2/css2400/sh_css_internal.h |   17 -
 2 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 7e337e0..aa19419 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -2015,34 +2015,25 @@ ia_css_enable_isys_event_queue(bool enable)
return IA_CSS_SUCCESS;
 }
 
-void *
-sh_css_malloc_ex(size_t size, const char *caller_func, int caller_line)
+void *sh_css_malloc(size_t size)
 {
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "sh_css_malloc() enter: 
size=%d\n",size);
-   (void)caller_func;
-   (void)caller_line;
if (size > 0 && my_css.malloc)
return my_css.malloc(size, false);
return NULL;
 }
 
-void *
-sh_css_calloc_ex(size_t N, size_t size, const char *caller_func, int 
caller_line)
+void *sh_css_calloc(size_t N, size_t size)
 {
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "sh_css_calloc() enter: N=%d, 
size=%d\n",N,size);
-   (void)caller_func;
-   (void)caller_line;
if (size > 0 && my_css.malloc)
return my_css.malloc(N*size, true); 
return NULL;
 }
 
-void
-sh_css_free_ex(void *ptr, const char *caller_func, int caller_line)
+void sh_css_free(void *ptr)
 {
IA_CSS_ENTER_PRIVATE("ptr = %p", ptr);
-   (void)caller_func;
-   (void)caller_line;
if (ptr && my_css.free)
my_css.free(ptr);
IA_CSS_LEAVE_PRIVATE("void");
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_internal.h 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_internal.h
index a108923..e2b6f06 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_internal.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_internal.h
@@ -1002,23 +1002,14 @@ sh_css_params_init(void);
 void
 sh_css_params_uninit(void);
 
-#define sh_css_malloc(size) sh_css_malloc_ex(size, __func__, __LINE__)
-#define sh_css_calloc(N, size) sh_css_calloc_ex(N, size, __func__, __LINE__)
-#define sh_css_free(ptr) sh_css_free_ex(ptr, __func__, __LINE__)
+void *sh_css_malloc(size_t size);
 
+void *sh_css_calloc(size_t N, size_t size);
 
-void *
-sh_css_malloc_ex(size_t size, const char *caller_func, int caller_line);
-
-void *
-sh_css_calloc_ex(size_t N, size_t size, const char *caller_func, int 
caller_lin);
-
-void
-sh_css_free_ex(void *ptr, const char *caller_func, int caller_line);
+void sh_css_free(void *ptr);
 
 /* For Acceleration API: Flush FW (shared buffer pointer) arguments */
-void
-sh_css_flush(struct ia_css_acc_fw *fw);
+void sh_css_flush(struct ia_css_acc_fw *fw);
 
 
 void



[PATCH 05/14] staging: atomisp: move mipi_info assignment to next line in __get_asd_from_port()

2017-04-12 Thread Alan Cox
From: Daeseok Youn 

The line which is initializing mipi_info variable is too long
to read. It would be placed in next line.

Signed-off-by: Daeseok Youn 
Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index d98a6ea..a8614a9 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -533,9 +533,11 @@ __get_asd_from_port(struct atomisp_device *isp, 
mipi_port_ID_t port)
/* Check which isp subdev to send eof */
for (i = 0; i < isp->num_of_streams; i++) {
struct atomisp_sub_device *asd = >asd[i];
-   struct camera_mipi_info *mipi_info =
-   atomisp_to_sensor_mipi_info(
-   isp->inputs[asd->input_curr].camera);
+   struct camera_mipi_info *mipi_info;
+
+   mipi_info = atomisp_to_sensor_mipi_info(
+   isp->inputs[asd->input_curr].camera);
+
if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
__get_mipi_port(isp, mipi_info->port) == port) {
return asd;



[PATCH 03/14] staging: atomisp: remove enable_isp_irq function and add disable_isp_irq

2017-04-12 Thread Alan Cox
From: Daeseok Youn 

Enable/Disable ISP irq is switched with "enable" parameter of
enable_isp_irq(). It would be better splited to two such as
enable_isp_irq()/disable_isp_irq().

But the enable_isp_irq() is no use in atomisp_cmd.c file.
So remove the enable_isp_irq() function and add
disable_isp_irq function only.

Signed-off-by: Daeseok Youn 
Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   |   36 +---
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 9ad5146..08606cb 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -376,34 +376,16 @@ int atomisp_reset(struct atomisp_device *isp)
 }
 
 /*
- * interrupt enable/disable functions
+ * interrupt disable functions
  */
-static void enable_isp_irq(enum hrt_isp_css_irq irq, bool enable)
-{
-   if (enable) {
-   irq_enable_channel(IRQ0_ID, irq);
-   /*sh_css_hrt_irq_enable(irq, true, false);*/
-   switch (irq) { /*We only have sp interrupt right now*/
-   case hrt_isp_css_irq_sp:
-   /*sh_css_hrt_irq_enable_sp(true);*/
-   cnd_sp_irq_enable(SP0_ID, true);
-   break;
-   default:
-   break;
-   }
+static void disable_isp_irq(enum hrt_isp_css_irq irq)
+{
+   irq_disable_channel(IRQ0_ID, irq);
 
-   } else {
-   /*sh_css_hrt_irq_disable(irq);*/
-   irq_disable_channel(IRQ0_ID, irq);
-   switch (irq) {
-   case hrt_isp_css_irq_sp:
-   /*sh_css_hrt_irq_enable_sp(false);*/
-   cnd_sp_irq_enable(SP0_ID, false);
-   break;
-   default:
-   break;
-   }
-   }
+   if (irq != hrt_isp_css_irq_sp)
+   return;
+
+   cnd_sp_irq_enable(SP0_ID, false);
 }
 
 /*
@@ -1416,7 +1398,7 @@ static void __atomisp_css_recover(struct atomisp_device 
*isp, bool isp_timeout)
}
 
/* clear irq */
-   enable_isp_irq(hrt_isp_css_irq_sp, false);
+   disable_isp_irq(hrt_isp_css_irq_sp);
clear_isp_irq(hrt_isp_css_irq_sp);
 
/* Set the SRSE to 3 before resetting */



[PATCH 04/14] staging: atomisp: replace ">asd[i]" with "asd" in __get_asd_from_port()

2017-04-12 Thread Alan Cox
From: Daeseok Youn 

The address of isp->asd[i] is already assigned to
local "asd" variable. ">asd[i]" would be replaced with
just "asd".

Signed-off-by: Daeseok Youn 
Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 08606cb..d98a6ea 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -536,9 +536,9 @@ __get_asd_from_port(struct atomisp_device *isp, 
mipi_port_ID_t port)
struct camera_mipi_info *mipi_info =
atomisp_to_sensor_mipi_info(
isp->inputs[asd->input_curr].camera);
-   if (isp->asd[i].streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
+   if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
__get_mipi_port(isp, mipi_info->port) == port) {
-   return >asd[i];
+   return asd;
}
}
 



[PATCH 02/14] staging/atomisp: fix spelling mistake: "falied" -> "failed"

2017-04-12 Thread Alan Cox
From: Colin Ian King 

trivial fix to spelling mistake in dev_err error message

Signed-off-by: Colin Ian King 
Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/hmm/hmm_bo_dev.c|2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo_dev.c 
b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo_dev.c
index 87090ce..d22a2d2 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo_dev.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo_dev.c
@@ -59,7 +59,7 @@ int hmm_bo_device_init(struct hmm_bo_device *bdev,
 
ret = hmm_vm_init(>vaddr_space, vaddr_start, size);
if (ret) {
-   dev_err(atomisp_dev, "hmm_vm_init falied. vaddr_start = 0x%x, 
size = %d\n",
+   dev_err(atomisp_dev, "hmm_vm_init failed. vaddr_start = 0x%x, 
size = %d\n",
vaddr_start, size);
goto vm_init_err;
}



[PATCH 01/14] staging: atomisp: use local variable to reduce number of references

2017-04-12 Thread Alan Cox
From: Daeseok Youn 

Define new local variable to reduce the number of reference.
The new local variable is added to save the addess of dfs
and used in atomisp_freq_scaling() function.

Signed-off-by: Daeseok Youn 
Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   |   37 +++-
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..9ad5146 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -251,6 +251,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
 {
/* FIXME! Only use subdev[0] status yet */
struct atomisp_sub_device *asd = >asd[0];
+   const struct atomisp_dfs_config *dfs;
unsigned int new_freq;
struct atomisp_freq_scaling_rule curr_rules;
int i, ret;
@@ -265,20 +266,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
isp->dfs = _config_cht_soc;
 
-   if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
-   isp->dfs->highest_freq == 0 || isp->dfs->dfs_table_size == 0 ||
-   !isp->dfs->dfs_table) {
+   dfs = isp->dfs;
+
+   if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
+   dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
+   !dfs->dfs_table) {
dev_err(isp->dev, "DFS configuration is invalid.\n");
return -EINVAL;
}
 
if (mode == ATOMISP_DFS_MODE_LOW) {
-   new_freq = isp->dfs->lowest_freq;
+   new_freq = dfs->lowest_freq;
goto done;
}
 
if (mode == ATOMISP_DFS_MODE_MAX) {
-   new_freq = isp->dfs->highest_freq;
+   new_freq = dfs->highest_freq;
goto done;
}
 
@@ -304,26 +307,26 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
}
 
/* search for the target frequency by looping freq rules*/
-   for (i = 0; i < isp->dfs->dfs_table_size; i++) {
-   if (curr_rules.width != isp->dfs->dfs_table[i].width &&
-   isp->dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
+   for (i = 0; i < dfs->dfs_table_size; i++) {
+   if (curr_rules.width != dfs->dfs_table[i].width &&
+   dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.height != isp->dfs->dfs_table[i].height &&
-   isp->dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
+   if (curr_rules.height != dfs->dfs_table[i].height &&
+   dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.fps != isp->dfs->dfs_table[i].fps &&
-   isp->dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
+   if (curr_rules.fps != dfs->dfs_table[i].fps &&
+   dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.run_mode != isp->dfs->dfs_table[i].run_mode &&
-   isp->dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
+   if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
+   dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
continue;
break;
}
 
-   if (i == isp->dfs->dfs_table_size)
-   new_freq = isp->dfs->max_freq_at_vmin;
+   if (i == dfs->dfs_table_size)
+   new_freq = dfs->max_freq_at_vmin;
else
-   new_freq = isp->dfs->dfs_table[i].isp_freq;
+   new_freq = dfs->dfs_table[i].isp_freq;
 
 done:
dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);



Re: please help with uninstall

2017-04-12 Thread Helen Koike

Hi,

On 2017-04-12 08:00 AM, Milan Čížek wrote:

How to remove your product from my kernel? I tried make rmmod
rminstall but this message stills in my syslog.
Sorry for question, I'm linux newbie.

[   15.753993] WARNING: You are using an experimental version of the
media stack.
As the driver is backported to an older kernel, it
doesn't offer
enough quality for its usage in production.
Use it with care.
   Latest git patches (needed if you report a bug to
linux-media@vger.kernel.org):
427ae153c65ad7a08288d86baf99000569627d03 [media]
bq/c-qcam, w9966, pms: move to staging in preparation for removal
ea2e813e8cc3492c951b9895724fd47187e04a6f [media]
tlg2300: move to staging in preparation for removal
c1d9e03d4ef47de60b414fa25f05f9c867f43c5a [media]
vino/saa7191: move to staging in preparation for removal

Milan



This message doesn't seem to be an error, after running rmmod does the 
driver still shows with lsmod?.
If you want to prevent a module to load at boot time you can add the 
driver in the blacklist file, its location depends on your distribution, 
check this example: 
http://askubuntu.com/questions/110341/how-to-blacklist-kernel-modules
Or you can recompile the kernel without this module, I can point you to 
some guides if you want to go to this direction.


Helen


Re: Looking for device driver advice

2017-04-12 Thread Hans Verkuil
On 04/12/2017 04:29 PM, Patrick Doyle wrote:
> Thank you again Hans.
> 
> On Wed, Apr 12, 2017 at 9:58 AM, Hans Verkuil  wrote:
>> On 04/12/2017 03:13 PM, Patrick Doyle wrote:
>>> The SAMA5 has a downsampler built into its LCD engine.  Suppose I
>>> wanted to treat that downsampler as an independent device and pass
>>> image buffers through that downsampler (the LCD display output is
>>> disabled in hardware when the device is configured in this mode)
>>> do you have any recommendations as to how I might structure a device
>>> driver to do that.  At it's core, it would DMA a buffer from memory,
>>> through the downsampler, and back into memory.  Is that something I
>>> might also wire in as a pseudo-subdev of the ISC?  Or is there a
>>> better abstraction for arbitrary image processing pipeline elements?
>>
>> I think this is out of scope of V4L2. Check with Atmel/Microchip.
> 
> The V4L2 tie-in is in answering the question: Is there a standard V4L2
> way to perform arbitrary video processing functions (such as
> downsampling) with an arbitrary device.  If the answer is "no", that's
> fine.  If the answer is, "yes, here is how Xilinx does it for their IP
> modules", then I'll go look at some Xilinx stuff (which I'm going to
> do anyway).

VIDIOC_S_FMT: the pixelformat you specify in the v4l2_pix_format struct
determines Bayer vs YUV 4:2:2 vs YUV 4:2:0 vs RGB.

So that triggers whatever conversion is needed to arrive at the desired
memory format.

https://www.linuxtv.org/downloads/v4l-dvb-apis-new/uapi/v4l/vidioc-g-fmt.html

Regards,

Hans



Re: Looking for device driver advice

2017-04-12 Thread Patrick Doyle
Thank you again Hans.

On Wed, Apr 12, 2017 at 9:58 AM, Hans Verkuil  wrote:
> On 04/12/2017 03:13 PM, Patrick Doyle wrote:
>> The SAMA5 has a downsampler built into its LCD engine.  Suppose I
>> wanted to treat that downsampler as an independent device and pass
>> image buffers through that downsampler (the LCD display output is
>> disabled in hardware when the device is configured in this mode)
>> do you have any recommendations as to how I might structure a device
>> driver to do that.  At it's core, it would DMA a buffer from memory,
>> through the downsampler, and back into memory.  Is that something I
>> might also wire in as a pseudo-subdev of the ISC?  Or is there a
>> better abstraction for arbitrary image processing pipeline elements?
>
> I think this is out of scope of V4L2. Check with Atmel/Microchip.

The V4L2 tie-in is in answering the question: Is there a standard V4L2
way to perform arbitrary video processing functions (such as
downsampling) with an arbitrary device.  If the answer is "no", that's
fine.  If the answer is, "yes, here is how Xilinx does it for their IP
modules", then I'll go look at some Xilinx stuff (which I'm going to
do anyway).

--wpd


[PATCH] [media] xc5000: fix spelling mistake: "calibration"

2017-04-12 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake on calibration, make Self lowercase
and re-join multiple lined printk since checkpatch allows this
coding style.

Signed-off-by: Colin Ian King 
---
 drivers/media/tuners/xc5000.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index 91947cf1950e..e823aafce276 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -1184,8 +1184,7 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend 
*fe, int force)
/* Start the tuner self-calibration process */
ret = xc_initialize(priv);
if (ret) {
-   printk(KERN_ERR
-  "xc5000: Can't request Self-callibration.");
+   printk(KERN_ERR "xc5000: Can't request 
self-calibration.");
continue;
}
 
-- 
2.11.0



Re: [RFC PATCH 3/3] encoder-tpd12s015: keep the ls_oe_gpio on while the phys_addr is valid

2017-04-12 Thread Hans Verkuil
On 04/12/2017 03:21 PM, Tomi Valkeinen wrote:
> On 12/04/17 16:03, Hans Verkuil wrote:
> 
>> I noticed while experimenting with this that tpd_disconnect() in
>> drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c isn't called when
>> I disconnect the HDMI cable. Is that a bug somewhere?
>>
>> I would expect that tpd_connect and tpd_disconnect are balanced. The 
>> tpd_enable
>> and tpd_disable calls are properly balanced and I see the tpd_disable when I
>> disconnect the HDMI cable.
> 
> The connect/disconnect naming there is legacy... It's not about cable
> connect, it's about the initial "connect" of the drivers in the video
> pipeline. It's done just once when starting omapdrm.

Ah, good to know.

>> The key to keeping CEC up and running, even when there is no HPD is to keep
>> the hdmi.vdda_reg regulator enabled. Also the HDMI_IRQ_CORE should always be
>> on, otherwise I won't get any CEC interrupts.
> 
> At the moment there's no way to enable the pipeline without enabling the
> video.
> 
>> So if the omap4 CEC support is enabled in the kernel config, then always 
>> enable
>> this regulator and irq, and otherwise keep the current code.
> 
> Well, I have no clue about how CEC is used, but don't we have some
> userspace components using it? I presume there's an open() or something
> similar that signals that the userspace is interested in CEC. That
> should be the trigger to enable the HW required for CEC.

Why didn't I think of that. I did a quick implementation to test this and it
works.

> So is some other driver supporting this already? Or is the omap4 the
> first platform you're trying this on?

No, there are quite a few CEC drivers by now, but typically the CEC block is
a totally independent IP block with its own power, irq, etc. The omap4 is by far
the most complex one to set up with various GPIO pins, interrupts, regulators,
etc. to deal with.

Normally it takes about 2 days to make a new CEC driver, but the omap4 is much
more work :-(

Regards,

Hans


Re: Looking for device driver advice

2017-04-12 Thread Hans Verkuil
On 04/12/2017 03:13 PM, Patrick Doyle wrote:
> Thank you Hans,
> I can modify (or work with Atmel/Microchip to have modified) the
> atmel-isc driver, so I that's not an issue.
> 
> With your feedback, I now have a target implementation to which I can aim.
> 
> For now, I'll be happy when I can get any image at all through my
> pipeline... wish me luck! :-)
> 
> On a similar vein... the image is much higher resolution than I need
> at the moment, so I will need to downsample it.
> 
> The SAMA5 has a downsampler built into its LCD engine.  Suppose I
> wanted to treat that downsampler as an independent device and pass
> image buffers through that downsampler (the LCD display output is
> disabled in hardware when the device is configured in this mode)
> do you have any recommendations as to how I might structure a device
> driver to do that.  At it's core, it would DMA a buffer from memory,
> through the downsampler, and back into memory.  Is that something I
> might also wire in as a pseudo-subdev of the ISC?  Or is there a
> better abstraction for arbitrary image processing pipeline elements?

I think this is out of scope of V4L2. Check with Atmel/Microchip.

> 
> Oh yeah, and speaking about arbitrary image processing pipeline
> elements, the Atmel ISC has a number of elements that could be enabled
> (but are not currently supported by the driver).  Is there a model to
> follow to enable features such as demosaicing, color space conversion,
> gamma correction, 4:2:2 to 4:2:0 downsampling, etc...

As far as I can see it already has support for colorspace conversion (I
presume you mean Bayer to YUV or RGB conversions) and ditto for 4:2:2 and
4:2:0. I see a gamma control as well.

Anyway, this is best discussed with your Atmel/Microchip contact.

Ah, I checked, this isn't upstream yet until kernel 4.12. It is in our
repo: https://git.linuxtv.org/media_tree.git/ in the master branch which
will feed into the mainline kernel.

> All of this is on the list of things that I need to get working... by
> next Tuesday ideally :-)
> (No, it's not really "next Tuesday", but you get the idea.)

Well, copying the atmel-isc code from our repo should help a lot :-)

Regards,

Hans

> 
> --wpd
> 
> 
> On Wed, Apr 12, 2017 at 7:37 AM, Hans Verkuil  wrote:
>> Hi Patrick,
>>
>> On 04/10/2017 10:13 PM, Patrick Doyle wrote:
>>> I am looking for advice regarding the construction of a device driver
>>> for a MIPI CSI2 imager (a Sony IMX241) that is connected to a
>>> MIPI<->Parallel converter (Toshiba TC358748) wired into a parallel
>>> interface on a Soc (a Microchip/Atmel SAMAD2x device.)
>>>
>>> The Sony imager is controlled and configured via I2C, as is the
>>> Toshiba converter.  I could write a single driver that configures both
>>> devices and treats them as a single device that just happens to use 2
>>> i2c addresses.  I could use the i2c_new_dummy() API to construct the
>>> device abstraction for the second physical device at probe time for
>>> the first physical device.
>>>
>>> Or I could do something smarter (or at least different), specifying
>>> the two devices independently via my device tree file, perhaps linking
>>> them together via "port" nodes.  Currently, I use the "port" node
>>> concept to link an i2c imager to the Image System Controller (isc)
>>> node in the SAMA5 device.  Perhaps that generalizes to a chain of
>>> nodes linked together... I don't know.
>>
>> That would be the right solution. Unfortunately the atmel-isc.c driver
>> (at least the version in the mainline kernel) only supports a single
>> subdev device. At least, as far as I can see.
>>
>> What you have is a video pipeline of 2 subdevs and the atmel-isc as DMA
>> engine:
>>
>> imx241 -> tc358748 -> atmel-isc
>>
>> connected in the device tree by ports.
>>
>> Looking at the code I think both subdev drivers would be loaded, but
>> the atmel-isc driver would only call ops from the tc358748.
>>
>> The v4l2_subdev_call functions in atmel-isc should most likely be replaced
>> by v4l2_device_call_all().
>>
>> But I don't have the tc358748 datasheet with the register information, so
>> I am not sure if this is sufficient.
>>
>>> I'm also not sure how these two devices might play into V4L2's
>>> "subdev" concept.  Are they separate, independent sub devices of the
>>> ISC, or are they a single sub device.
>>
>> subdev drivers are standalone drivers for, among others, i2c devices. The
>> top-level driver (atmel-isc + the device tree) is what pulls everything 
>> together.
>>
>> This allows us to reuse such subdev drivers on other devices.
>>
>> Regards,
>>
>> Hans
>>
>>>
>>> Any thoughts, intuition, pointers to existing code that addresses
>>> questions such as these, would be welcome.
>>>
>>> Thanks.
>>>
>>> --wpd
>>>
>>



Re: [RFC PATCH 3/3] encoder-tpd12s015: keep the ls_oe_gpio on while the phys_addr is valid

2017-04-12 Thread Tomi Valkeinen
On 12/04/17 16:03, Hans Verkuil wrote:

> I noticed while experimenting with this that tpd_disconnect() in
> drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c isn't called when
> I disconnect the HDMI cable. Is that a bug somewhere?
> 
> I would expect that tpd_connect and tpd_disconnect are balanced. The 
> tpd_enable
> and tpd_disable calls are properly balanced and I see the tpd_disable when I
> disconnect the HDMI cable.

The connect/disconnect naming there is legacy... It's not about cable
connect, it's about the initial "connect" of the drivers in the video
pipeline. It's done just once when starting omapdrm.

> The key to keeping CEC up and running, even when there is no HPD is to keep
> the hdmi.vdda_reg regulator enabled. Also the HDMI_IRQ_CORE should always be
> on, otherwise I won't get any CEC interrupts.

At the moment there's no way to enable the pipeline without enabling the
video.

> So if the omap4 CEC support is enabled in the kernel config, then always 
> enable
> this regulator and irq, and otherwise keep the current code.

Well, I have no clue about how CEC is used, but don't we have some
userspace components using it? I presume there's an open() or something
similar that signals that the userspace is interested in CEC. That
should be the trigger to enable the HW required for CEC.

So is some other driver supporting this already? Or is the omap4 the
first platform you're trying this on?

 Tomi



signature.asc
Description: OpenPGP digital signature


Re: Looking for device driver advice

2017-04-12 Thread Patrick Doyle
Thank you Hans,
I can modify (or work with Atmel/Microchip to have modified) the
atmel-isc driver, so I that's not an issue.

With your feedback, I now have a target implementation to which I can aim.

For now, I'll be happy when I can get any image at all through my
pipeline... wish me luck! :-)

On a similar vein... the image is much higher resolution than I need
at the moment, so I will need to downsample it.

The SAMA5 has a downsampler built into its LCD engine.  Suppose I
wanted to treat that downsampler as an independent device and pass
image buffers through that downsampler (the LCD display output is
disabled in hardware when the device is configured in this mode)
do you have any recommendations as to how I might structure a device
driver to do that.  At it's core, it would DMA a buffer from memory,
through the downsampler, and back into memory.  Is that something I
might also wire in as a pseudo-subdev of the ISC?  Or is there a
better abstraction for arbitrary image processing pipeline elements?

Oh yeah, and speaking about arbitrary image processing pipeline
elements, the Atmel ISC has a number of elements that could be enabled
(but are not currently supported by the driver).  Is there a model to
follow to enable features such as demosaicing, color space conversion,
gamma correction, 4:2:2 to 4:2:0 downsampling, etc...

All of this is on the list of things that I need to get working... by
next Tuesday ideally :-)
(No, it's not really "next Tuesday", but you get the idea.)

--wpd


On Wed, Apr 12, 2017 at 7:37 AM, Hans Verkuil  wrote:
> Hi Patrick,
>
> On 04/10/2017 10:13 PM, Patrick Doyle wrote:
>> I am looking for advice regarding the construction of a device driver
>> for a MIPI CSI2 imager (a Sony IMX241) that is connected to a
>> MIPI<->Parallel converter (Toshiba TC358748) wired into a parallel
>> interface on a Soc (a Microchip/Atmel SAMAD2x device.)
>>
>> The Sony imager is controlled and configured via I2C, as is the
>> Toshiba converter.  I could write a single driver that configures both
>> devices and treats them as a single device that just happens to use 2
>> i2c addresses.  I could use the i2c_new_dummy() API to construct the
>> device abstraction for the second physical device at probe time for
>> the first physical device.
>>
>> Or I could do something smarter (or at least different), specifying
>> the two devices independently via my device tree file, perhaps linking
>> them together via "port" nodes.  Currently, I use the "port" node
>> concept to link an i2c imager to the Image System Controller (isc)
>> node in the SAMA5 device.  Perhaps that generalizes to a chain of
>> nodes linked together... I don't know.
>
> That would be the right solution. Unfortunately the atmel-isc.c driver
> (at least the version in the mainline kernel) only supports a single
> subdev device. At least, as far as I can see.
>
> What you have is a video pipeline of 2 subdevs and the atmel-isc as DMA
> engine:
>
> imx241 -> tc358748 -> atmel-isc
>
> connected in the device tree by ports.
>
> Looking at the code I think both subdev drivers would be loaded, but
> the atmel-isc driver would only call ops from the tc358748.
>
> The v4l2_subdev_call functions in atmel-isc should most likely be replaced
> by v4l2_device_call_all().
>
> But I don't have the tc358748 datasheet with the register information, so
> I am not sure if this is sufficient.
>
>> I'm also not sure how these two devices might play into V4L2's
>> "subdev" concept.  Are they separate, independent sub devices of the
>> ISC, or are they a single sub device.
>
> subdev drivers are standalone drivers for, among others, i2c devices. The
> top-level driver (atmel-isc + the device tree) is what pulls everything 
> together.
>
> This allows us to reuse such subdev drivers on other devices.
>
> Regards,
>
> Hans
>
>>
>> Any thoughts, intuition, pointers to existing code that addresses
>> questions such as these, would be welcome.
>>
>> Thanks.
>>
>> --wpd
>>
>


Re: [RFC PATCH 3/3] encoder-tpd12s015: keep the ls_oe_gpio on while the phys_addr is valid

2017-04-12 Thread Hans Verkuil
On 04/12/2017 03:03 PM, Hans Verkuil wrote:
> Hi Tomi,
> 
> On 04/10/2017 01:59 PM, Tomi Valkeinen wrote:
>> On 08/04/17 13:11, Hans Verkuil wrote:
>>
>>> So, this is a bit of a blast from the past since the omap4 CEC development
>>> has been on hold for almost a year. But I am about to resume my work on this
>>> now that the CEC framework was merged.
>>>
>>> The latest code is here, if you are interested:
>>>
>>> https://git.linuxtv.org/hverkuil/media_tree.git/log/?h=panda-cec
>>>
>>> It's pretty much unchanged from the version I posted a year ago, just 
>>> rebased.
>>>
>>> But before I continue with this I have one question for you. First some
>>> background:
>>>
>>> There is a special corner case (and I wasn't aware of that a year ago!) 
>>> where
>>> it is allowed to send a CEC message when there is *no HPD*.
>>>
>>> The reason is that some displays turn off the hotplug detect pin when they 
>>> go
>>> into standby or when another input is active. The only way to communicate 
>>> with
>>> such displays is via CEC.
>>>
>>> The problem is that without a HPD there is no EDID and basically no way for 
>>> an
>>> HDMI transmitter to detect that something is connected at all, unless you 
>>> are
>>> using CEC.
>>>
>>> What this means is that if we want to implement this on the omap4 the CEC 
>>> support
>>> has to be on all the time.
>>>
>>> We have seen modern displays that behave like this, so this is a real 
>>> issue. And
>>> this corner case is specifically allowed by the CEC specification: the Poll,
>>> Image/Text View On and the Active Source messages can be sent to a TV even 
>>> when
>>> there is no HPD in order to turn on the display if it was in standby and to 
>>> make
>>> us the active input.
>>>
>>> The CEC framework in the kernel supports this starting with 4.12 (this code 
>>> is
>>> in the panda-cec branch above).
>>>
>>> If this *can't* be supported by the omap4, then I will likely have to add a 
>>> CEC
>>> capability to signal to the application that this specific corner case is 
>>> not
>>> supported.
>>>
>>> I just did some tests with omap4 and I my impression is that this can't be
>>> supported: when the HPD goes away it seems like most/all of the HDMI blocks 
>>> are
>>> all powered off and any attempt to even access the CEC registers will fail.
>>>
>>> Changing this looks to be non-trivial if not impossible.
>>>
>>> Can you confirm that that isn't possible? If you think this can be done, 
>>> then
>>> I'd appreciate if you can give me a few pointers.
>>
>> HPD doesn't control the HW, it's all in the SW. So while I don't know
>> much at all about CEC and haven't looked at this particular use case, I
>> believe it's doable. HPD going off will make the DRM connector to be in
>> "disconnected" state, which on omapdrm will cause everything about HDMI
>> to be turned off.
>>
>> Does it work on some other DRM driver? I'm wondering if there's
>> something in the DRM framework side that also has to be changed, in
>> addition to omapdrm changes.
>>
>> It could require larger SW redesigns, though... Which makes me think
>> that the work shouldn't be done until we have changed the omapdrm's
>> driver model to DRM's common bridge driver model, and then all this
>> could possibly be done in a more generic manner.
>>
>> Well, then again, I think the hdmi driver's internal power state
>> handling could be improved even before that. Currently it's not very
>> versatile. We should have ways to partially enable the IP for just the
>> required parts.
> 
> I noticed while experimenting with this that tpd_disconnect() in
> drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c isn't called when
> I disconnect the HDMI cable. Is that a bug somewhere?
> 
> I would expect that tpd_connect and tpd_disconnect are balanced. The 
> tpd_enable
> and tpd_disable calls are properly balanced and I see the tpd_disable when I
> disconnect the HDMI cable.
> 
> The key to keeping CEC up and running, even when there is no HPD is to keep
> the hdmi.vdda_reg regulator enabled. Also the HDMI_IRQ_CORE should always be
> on, otherwise I won't get any CEC interrupts.
> 
> So if the omap4 CEC support is enabled in the kernel config, then always 
> enable
> this regulator and irq, and otherwise keep the current code.

And of course the ls_oe_gpio in tpd12s015.c should always be high as well, 
otherwise
the CEC signal would never get through. This too can depend on the kernel 
config.

Hans

> 
> Does that look sensible to you?
> 
> Regards,
> 
>   Hans
> 



Re: [RFC PATCH 3/3] encoder-tpd12s015: keep the ls_oe_gpio on while the phys_addr is valid

2017-04-12 Thread Hans Verkuil
Hi Tomi,

On 04/10/2017 01:59 PM, Tomi Valkeinen wrote:
> On 08/04/17 13:11, Hans Verkuil wrote:
> 
>> So, this is a bit of a blast from the past since the omap4 CEC development
>> has been on hold for almost a year. But I am about to resume my work on this
>> now that the CEC framework was merged.
>>
>> The latest code is here, if you are interested:
>>
>> https://git.linuxtv.org/hverkuil/media_tree.git/log/?h=panda-cec
>>
>> It's pretty much unchanged from the version I posted a year ago, just 
>> rebased.
>>
>> But before I continue with this I have one question for you. First some
>> background:
>>
>> There is a special corner case (and I wasn't aware of that a year ago!) where
>> it is allowed to send a CEC message when there is *no HPD*.
>>
>> The reason is that some displays turn off the hotplug detect pin when they go
>> into standby or when another input is active. The only way to communicate 
>> with
>> such displays is via CEC.
>>
>> The problem is that without a HPD there is no EDID and basically no way for 
>> an
>> HDMI transmitter to detect that something is connected at all, unless you are
>> using CEC.
>>
>> What this means is that if we want to implement this on the omap4 the CEC 
>> support
>> has to be on all the time.
>>
>> We have seen modern displays that behave like this, so this is a real issue. 
>> And
>> this corner case is specifically allowed by the CEC specification: the Poll,
>> Image/Text View On and the Active Source messages can be sent to a TV even 
>> when
>> there is no HPD in order to turn on the display if it was in standby and to 
>> make
>> us the active input.
>>
>> The CEC framework in the kernel supports this starting with 4.12 (this code 
>> is
>> in the panda-cec branch above).
>>
>> If this *can't* be supported by the omap4, then I will likely have to add a 
>> CEC
>> capability to signal to the application that this specific corner case is not
>> supported.
>>
>> I just did some tests with omap4 and I my impression is that this can't be
>> supported: when the HPD goes away it seems like most/all of the HDMI blocks 
>> are
>> all powered off and any attempt to even access the CEC registers will fail.
>>
>> Changing this looks to be non-trivial if not impossible.
>>
>> Can you confirm that that isn't possible? If you think this can be done, then
>> I'd appreciate if you can give me a few pointers.
> 
> HPD doesn't control the HW, it's all in the SW. So while I don't know
> much at all about CEC and haven't looked at this particular use case, I
> believe it's doable. HPD going off will make the DRM connector to be in
> "disconnected" state, which on omapdrm will cause everything about HDMI
> to be turned off.
> 
> Does it work on some other DRM driver? I'm wondering if there's
> something in the DRM framework side that also has to be changed, in
> addition to omapdrm changes.
> 
> It could require larger SW redesigns, though... Which makes me think
> that the work shouldn't be done until we have changed the omapdrm's
> driver model to DRM's common bridge driver model, and then all this
> could possibly be done in a more generic manner.
> 
> Well, then again, I think the hdmi driver's internal power state
> handling could be improved even before that. Currently it's not very
> versatile. We should have ways to partially enable the IP for just the
> required parts.

I noticed while experimenting with this that tpd_disconnect() in
drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c isn't called when
I disconnect the HDMI cable. Is that a bug somewhere?

I would expect that tpd_connect and tpd_disconnect are balanced. The tpd_enable
and tpd_disable calls are properly balanced and I see the tpd_disable when I
disconnect the HDMI cable.

The key to keeping CEC up and running, even when there is no HPD is to keep
the hdmi.vdda_reg regulator enabled. Also the HDMI_IRQ_CORE should always be
on, otherwise I won't get any CEC interrupts.

So if the omap4 CEC support is enabled in the kernel config, then always enable
this regulator and irq, and otherwise keep the current code.

Does that look sensible to you?

Regards,

Hans


[GIT PULL FOR v4.12] Add vimc virtual test driver

2017-04-12 Thread Hans Verkuil
Finally merge this for 4.12.

Regards,

Hans

The following changes since commit 4aed35ca73f6d9cfd5f7089ba5d04f5fb8623080:

  [media] v4l2-tpg: don't clamp XV601/709 to lim range (2017-04-10 14:58:06 
-0300)

are available in the git repository at:

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

for you to fetch changes up to 32d8d75a9af8c1169a33f8e1231f871459d1e4f0:

  vimc: Virtual Media Controller core, capture and sensor (2017-04-12 14:43:13 
+0200)


Helen Koike (1):
  vimc: Virtual Media Controller core, capture and sensor

 MAINTAINERS|   8 +
 drivers/media/platform/Kconfig |   2 +
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/vimc/Kconfig|  14 ++
 drivers/media/platform/vimc/Makefile   |   3 +
 drivers/media/platform/vimc/vimc-capture.c | 498 
+
 drivers/media/platform/vimc/vimc-capture.h |  28 +++
 drivers/media/platform/vimc/vimc-core.c| 695 
+
 drivers/media/platform/vimc/vimc-core.h| 112 ++
 drivers/media/platform/vimc/vimc-sensor.c  | 276 +++
 drivers/media/platform/vimc/vimc-sensor.h  |  28 +++
 11 files changed, 1665 insertions(+)
 create mode 100644 drivers/media/platform/vimc/Kconfig
 create mode 100644 drivers/media/platform/vimc/Makefile
 create mode 100644 drivers/media/platform/vimc/vimc-capture.c
 create mode 100644 drivers/media/platform/vimc/vimc-capture.h
 create mode 100644 drivers/media/platform/vimc/vimc-core.c
 create mode 100644 drivers/media/platform/vimc/vimc-core.h
 create mode 100644 drivers/media/platform/vimc/vimc-sensor.c
 create mode 100644 drivers/media/platform/vimc/vimc-sensor.h


Re: Looking for device driver advice

2017-04-12 Thread Hans Verkuil
Hi Patrick,

On 04/10/2017 10:13 PM, Patrick Doyle wrote:
> I am looking for advice regarding the construction of a device driver
> for a MIPI CSI2 imager (a Sony IMX241) that is connected to a
> MIPI<->Parallel converter (Toshiba TC358748) wired into a parallel
> interface on a Soc (a Microchip/Atmel SAMAD2x device.)
> 
> The Sony imager is controlled and configured via I2C, as is the
> Toshiba converter.  I could write a single driver that configures both
> devices and treats them as a single device that just happens to use 2
> i2c addresses.  I could use the i2c_new_dummy() API to construct the
> device abstraction for the second physical device at probe time for
> the first physical device.
> 
> Or I could do something smarter (or at least different), specifying
> the two devices independently via my device tree file, perhaps linking
> them together via "port" nodes.  Currently, I use the "port" node
> concept to link an i2c imager to the Image System Controller (isc)
> node in the SAMA5 device.  Perhaps that generalizes to a chain of
> nodes linked together... I don't know.

That would be the right solution. Unfortunately the atmel-isc.c driver
(at least the version in the mainline kernel) only supports a single
subdev device. At least, as far as I can see.

What you have is a video pipeline of 2 subdevs and the atmel-isc as DMA
engine:

imx241 -> tc358748 -> atmel-isc

connected in the device tree by ports.

Looking at the code I think both subdev drivers would be loaded, but
the atmel-isc driver would only call ops from the tc358748.

The v4l2_subdev_call functions in atmel-isc should most likely be replaced
by v4l2_device_call_all().

But I don't have the tc358748 datasheet with the register information, so
I am not sure if this is sufficient.

> I'm also not sure how these two devices might play into V4L2's
> "subdev" concept.  Are they separate, independent sub devices of the
> ISC, or are they a single sub device.

subdev drivers are standalone drivers for, among others, i2c devices. The
top-level driver (atmel-isc + the device tree) is what pulls everything 
together.

This allows us to reuse such subdev drivers on other devices.

Regards,

Hans

> 
> Any thoughts, intuition, pointers to existing code that addresses
> questions such as these, would be welcome.
> 
> Thanks.
> 
> --wpd
> 



[GIT PULL FOR v4.12] New ov5645 and ov5647 drivers

2017-04-12 Thread Hans Verkuil
Add the ov5645 and ov5647 drivers.

This supersedes an earlier ov5645-only pull request. Having separate pull 
requests
for these drivers would create a Kconfig conflict, so I've combined them in one
pull request.

Regards,

Hans

The following changes since commit 4aed35ca73f6d9cfd5f7089ba5d04f5fb8623080:

  [media] v4l2-tpg: don't clamp XV601/709 to lim range (2017-04-10 14:58:06 
-0300)

are available in the git repository at:

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

for you to fetch changes up to c95be7ca24262d62107b645f08653168afe9c3c3:

  media: i2c: Add support for OV5647 sensor. (2017-04-12 13:16:05 +0200)


Ramiro Oliveira (2):
  Documentation: DT: Add OV5647 bindings
  media: i2c: Add support for OV5647 sensor.

Todor Tomov (2):
  media: i2c/ov5645: add the device tree binding document
  media: Add a driver for the ov5645 camera sensor.

 Documentation/devicetree/bindings/media/i2c/ov5645.txt |   54 ++
 Documentation/devicetree/bindings/media/i2c/ov5647.txt |   35 ++
 MAINTAINERS|7 +
 drivers/media/i2c/Kconfig  |   23 +
 drivers/media/i2c/Makefile |2 +
 drivers/media/i2c/ov5645.c | 1345 

 drivers/media/i2c/ov5647.c |  634 
+
 7 files changed, 2100 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5645.txt
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5647.txt
 create mode 100644 drivers/media/i2c/ov5645.c
 create mode 100644 drivers/media/i2c/ov5647.c


please help with uninstall

2017-04-12 Thread Milan Čížek
How to remove your product from my kernel? I tried make rmmod rminstall but 
this message stills in my syslog.
Sorry for question, I'm linux newbie.

[   15.753993] WARNING: You are using an experimental version of the media 
stack.
    As the driver is backported to an older kernel, it doesn't offer
    enough quality for its usage in production.
    Use it with care.
   Latest git patches (needed if you report a bug to 
linux-media@vger.kernel.org):
    427ae153c65ad7a08288d86baf99000569627d03 [media] bq/c-qcam, 
w9966, pms: move to staging in preparation for removal
    ea2e813e8cc3492c951b9895724fd47187e04a6f [media] tlg2300: move 
to staging in preparation for removal
    c1d9e03d4ef47de60b414fa25f05f9c867f43c5a [media] vino/saa7191: 
move to staging in preparation for removal

Milan



Re: [PATCH v6 17/39] platform: add video-multiplexer subdevice driver

2017-04-12 Thread Sakari Ailus
Hi Steve,

On Tue, Apr 11, 2017 at 05:50:58PM -0700, Steve Longerbeam wrote:
> 
> 
> On 04/04/2017 05:47 AM, Sakari Ailus wrote:
> >Hi Steve, Philipp and Pavel,
> >
> >On Mon, Mar 27, 2017 at 05:40:34PM -0700, Steve Longerbeam wrote:
> >>From: Philipp Zabel 
> >>
> >>This driver can handle SoC internal and external video bus multiplexers,
> >>controlled either by register bit fields or by a GPIO. The subdevice
> >>passes through frame interval and mbus configuration of the active input
> >>to the output side.
> >
> >The MUX framework is already in linux-next. Could you use that instead of
> >adding new driver + bindings that are not compliant with the MUX framework?
> >I don't think it'd be much of a change in terms of code, using the MUX
> >framework appears quite simple.
> 
> I would prefer to wait on this, and get what we have merged now so I can
> unload all these patches first.

The DT bindings will be different for this one and if you were using a MUX,
won't they? And you can't remove support for the existing bindings either,
you have to continue to support them going forward.

> 
> Also this is Philipp's driver, so again I would prefer to get this
> merged as-is and then Philipp can address these issues in a future
> patch. But I will add my comments below...

I bet there will be more issues to handle if you were to do the changes
later than now.

...

> >>+static int vidsw_s_stream(struct v4l2_subdev *sd, int enable)
> >>+{
> >>+   struct vidsw *vidsw = v4l2_subdev_to_vidsw(sd);
> >>+   struct v4l2_subdev *upstream_sd;
> >>+   struct media_pad *pad;
> >>+
> >>+   if (vidsw->active == -1) {
> >>+   dev_err(sd->dev, "Can not start streaming on inactive mux\n");
> >>+   return -EINVAL;
> >>+   }
> >>+
> >>+   pad = media_entity_remote_pad(>entity.pads[vidsw->active]);
> >>+   if (!pad) {
> >>+   dev_err(sd->dev, "Failed to find remote source pad\n");
> >>+   return -ENOLINK;
> >>+   }
> >>+
> >>+   if (!is_media_entity_v4l2_subdev(pad->entity)) {
> >>+   dev_err(sd->dev, "Upstream entity is not a v4l2 subdev\n");
> >>+   return -ENODEV;
> >>+   }
> >>+
> >>+   upstream_sd = media_entity_to_v4l2_subdev(pad->entity);
> >>+
> >>+   return v4l2_subdev_call(upstream_sd, video, s_stream, enable);
> >
> >Now that we'll have more than two drivers involved in the same pipeline it
> >becomes necessary to define the behaviour of s_stream() throughout the
> >pipeline --- i.e. whose responsibility is it to call s_stream() on the
> >sub-devices in the pipeline?
> 
> In the case of imx-media, the capture device calls set stream on the
> whole pipeline in the start_streaming() callback. This subdev call is
> actually a NOOP for imx-media, because the upstream entity has already
> started streaming. Again I think this should be removed. It also
> enforces a stream order that some MC drivers may have a problem with.

What I want to say here is that the order in which the different devices in
the pipeline need to be started may not be known in a driver for a
particular part of the pipeline.

In order to avoid trying to have a single point of decision making, the
s_stream() op implemented in sub-device drivers should serve the purpose.
I'll cc you for the documentation patch.

-- 
Kind regards,

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


Re: [PATCH] [media] imx: csi: retain current field order and colorimetry setting as default

2017-04-12 Thread Hans Verkuil
On 04/06/2017 06:01 PM, Philipp Zabel wrote:
> On Thu, 2017-04-06 at 17:43 +0200, Hans Verkuil wrote:
>> On 04/06/2017 04:54 PM, Philipp Zabel wrote:
>>> On Thu, 2017-04-06 at 16:20 +0200, Hans Verkuil wrote:
 On 04/06/2017 03:55 PM, Philipp Zabel wrote:
> If the the field order is set to ANY in set_fmt, choose the currently
> set field order. If the colorspace is set to DEFAULT, choose the current
> colorspace.  If any of xfer_func, ycbcr_enc or quantization are set to
> DEFAULT, either choose the current setting, or the default setting for the
> new colorspace, if non-DEFAULT colorspace was given.
>
> This allows to let field order and colorimetry settings be propagated
> from upstream by calling media-ctl on the upstream entity source pad,
> and then call media-ctl on the sink pad to manually set the input frame
> interval, without changing the already set field order and colorimetry
> information.
>
> Signed-off-by: Philipp Zabel 
> ---
> This is based on imx-media-staging-md-v14, and it is supposed to allow
> configuring the pipeline with media-ctl like this:
>
> 1) media-ctl --set-v4l2 "'tc358743 1-000f':0[fmt:UYVY8_1X16/1920x1080]"
> 2) media-ctl --set-v4l2 "'imx6-mipi-csi2':1[fmt:UYVY8_1X16/1920x108]"
> 3) media-ctl --set-v4l2 "'ipu1_csi0_mux':2[fmt:UYVY8_1X16/1920x1080]"
> 4) media-ctl --set-v4l2 "'ipu1_csi0':0[fmt:UYVY8_1X16/1920x1080@1/60]"
> 5) media-ctl --set-v4l2 "'ipu1_csi0':2[fmt:AYUV32/1920x1080@1/30]"
>
> Without having step 4) overwrite the colorspace and field order set on
> 'ipu1_csi0':0 by the propagation in step 3).
> ---
>  drivers/staging/media/imx/imx-media-csi.c | 34 
> +++
>  1 file changed, 34 insertions(+)
>
> diff --git a/drivers/staging/media/imx/imx-media-csi.c 
> b/drivers/staging/media/imx/imx-media-csi.c
> index 64dc454f6b371..d94ce1de2bf05 100644
> --- a/drivers/staging/media/imx/imx-media-csi.c
> +++ b/drivers/staging/media/imx/imx-media-csi.c
> @@ -1325,6 +1325,40 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
>   csi_try_fmt(priv, sensor, cfg, sdformat, crop, compose, );
>  
>   fmt = __csi_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
> +
> + /* Retain current field setting as default */
> + if (sdformat->format.field == V4L2_FIELD_ANY)
> + sdformat->format.field = fmt->field;

 sdformat->format.field should never be FIELD_ANY. If it is, then that's a
 subdev bug and I'm pretty sure FIELD_NONE was intended.
>>>
>>> This is the subdev. sdformat is passed in from userspace, so we have to
>>> deal with it being set to ANY. I'm trying hard right now not to return
>>> ANY though. The values in sdformat->format are applied to fmt down
>>> below.
>>
>> Do you have a git tree with this patch? It is really hard to review without
>> having the full imx-media-csi.c source.
> 
> The patch applies on top of
> 
>   https://github.com/slongerbeam/mediatree.git imx-media-staging-md-v14
> 
> I have uploaded a branch
> 
>   git://git.pengutronix.de/git/pza/linux imx-media-staging-md-v14+color
> 
> with the patch applied on top.
> 
>> I think one problem is that it is not clearly defined how subdevs and 
>> colorspace
>> information should work.

Ah, having the full source helped.

Ignore my previous review, it was incorrect.

I'll have to think about this some more. I'll get back to this, but it may take 
some
time since my vacation starts tomorrow. The spec is simply unclear about how to 
handle
this so we have to come up with some guidelines.

Regards,

Hans