cron job: media_tree daily build: ERRORS

2018-04-22 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:   Mon Apr 23 05:00:10 CEST 2018
media-tree git hash:1d338b86e17d87215cf57b1ad1d13b2afe582d33
media_build git hash:   4fb7a3cc8d0f56c7cddc3b5b29e35aa1159bc8d9
v4l-utils git hash: 9a4acdbe53884e5a433c1295eead61e45b0718e7
gcc version:i686-linux-gcc (GCC) 7.3.0
sparse version: 0.5.2-RC1
smatch version: 0.5.1
host hardware:  x86_64
host os:4.15.0-2-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: OK
linux-git-arm-stm32: OK
linux-git-arm64: OK
linux-git-i686: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
Check COMPILE_TEST: WARNINGS: VIDEO_OMAP3 VIDEO_OMAP3_DEBUG
linux-2.6.36.4-i686: ERRORS
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.101-i686: ERRORS
linux-3.0.101-x86_64: ERRORS
linux-3.1.10-i686: OK
linux-3.1.10-x86_64: OK
linux-3.2.101-i686: OK
linux-3.2.101-x86_64: OK
linux-3.3.8-i686: OK
linux-3.3.8-x86_64: OK
linux-3.4.113-i686: OK
linux-3.4.113-x86_64: OK
linux-3.5.7-i686: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-i686: OK
linux-3.6.11-x86_64: OK
linux-3.7.10-i686: OK
linux-3.7.10-x86_64: OK
linux-3.8.13-i686: OK
linux-3.8.13-x86_64: OK
linux-3.9.11-i686: OK
linux-3.9.11-x86_64: OK
linux-3.10.108-i686: WARNINGS
linux-3.10.108-x86_64: WARNINGS
linux-3.11.10-i686: OK
linux-3.11.10-x86_64: OK
linux-3.12.74-i686: OK
linux-3.12.74-x86_64: OK
linux-3.13.11-i686: OK
linux-3.13.11-x86_64: OK
linux-3.14.79-i686: OK
linux-3.14.79-x86_64: OK
linux-3.15.10-i686: OK
linux-3.15.10-x86_64: OK
linux-3.16.56-i686: OK
linux-3.16.56-x86_64: OK
linux-3.17.8-i686: OK
linux-3.17.8-x86_64: OK
linux-3.18.102-i686: OK
linux-3.18.102-x86_64: OK
linux-3.19.8-i686: OK
linux-3.19.8-x86_64: OK
linux-4.0.9-i686: OK
linux-4.0.9-x86_64: OK
linux-4.1.51-i686: OK
linux-4.1.51-x86_64: OK
linux-4.2.8-i686: OK
linux-4.2.8-x86_64: OK
linux-4.3.6-i686: OK
linux-4.3.6-x86_64: OK
linux-4.4.109-i686: OK
linux-4.4.109-x86_64: OK
linux-4.5.7-i686: OK
linux-4.5.7-x86_64: OK
linux-4.6.7-i686: OK
linux-4.6.7-x86_64: OK
linux-4.7.10-i686: OK
linux-4.7.10-x86_64: OK
linux-4.8.17-i686: OK
linux-4.8.17-x86_64: OK
linux-4.9.91-i686: OK
linux-4.9.91-x86_64: OK
linux-4.14.31-i686: OK
linux-4.14.31-x86_64: OK
linux-4.15.14-i686: OK
linux-4.15.14-x86_64: OK
linux-4.16-i686: OK
linux-4.16-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: OK

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


[PATCH v3][RESEND] media: i2c: tda1997: replace codec to component

2018-04-22 Thread Kuninori Morimoto

From: Kuninori Morimoto 

Now we can replace Codec to Component. Let's do it.

Note:
xxx_codec_xxx() ->  xxx_component_xxx()
.idle_bias_off = 0  ->  .idle_bias_on = 1
.ignore_pmdown_time = 0 ->  .use_pmdown_time = 1
-   ->  .endianness = 1
-   ->  .non_legacy_dai_naming = 1

Signed-off-by: Kuninori Morimoto 
---
Tim, Mauro

2 weeks passed. I re-send.
This replace patch is needed for ALSA SoC, otherwise it can't probe anymore.

v2 -> v3

 - fixup driver name (= tda1997)

 drivers/media/i2c/tda1997x.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
index 3021913..33d7fcf 100644
--- a/drivers/media/i2c/tda1997x.c
+++ b/drivers/media/i2c/tda1997x.c
@@ -2444,7 +2444,7 @@ static int tda1997x_pcm_startup(struct snd_pcm_substream 
*substream,
struct snd_soc_dai *dai)
 {
struct tda1997x_state *state = snd_soc_dai_get_drvdata(dai);
-   struct snd_soc_codec *codec = dai->codec;
+   struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *rtd = substream->runtime;
int rate, err;
 
@@ -2452,11 +2452,11 @@ static int tda1997x_pcm_startup(struct 
snd_pcm_substream *substream,
err = snd_pcm_hw_constraint_minmax(rtd, SNDRV_PCM_HW_PARAM_RATE,
   rate, rate);
if (err < 0) {
-   dev_err(codec->dev, "failed to constrain samplerate to %dHz\n",
+   dev_err(component->dev, "failed to constrain samplerate to 
%dHz\n",
rate);
return err;
}
-   dev_info(codec->dev, "set samplerate constraint to %dHz\n", rate);
+   dev_info(component->dev, "set samplerate constraint to %dHz\n", rate);
 
return 0;
 }
@@ -2479,20 +2479,22 @@ static int tda1997x_pcm_startup(struct 
snd_pcm_substream *substream,
.ops = _dai_ops,
 };
 
-static int tda1997x_codec_probe(struct snd_soc_codec *codec)
+static int tda1997x_codec_probe(struct snd_soc_component *component)
 {
return 0;
 }
 
-static int tda1997x_codec_remove(struct snd_soc_codec *codec)
+static void tda1997x_codec_remove(struct snd_soc_component *component)
 {
-   return 0;
 }
 
-static struct snd_soc_codec_driver tda1997x_codec_driver = {
-   .probe = tda1997x_codec_probe,
-   .remove = tda1997x_codec_remove,
-   .reg_word_size = sizeof(u16),
+static struct snd_soc_component_driver tda1997x_codec_driver = {
+   .probe  = tda1997x_codec_probe,
+   .remove = tda1997x_codec_remove,
+   .idle_bias_on   = 1,
+   .use_pmdown_time= 1,
+   .endianness = 1,
+   .non_legacy_dai_naming  = 1,
 };
 
 static int tda1997x_probe(struct i2c_client *client,
@@ -2737,7 +2739,7 @@ static int tda1997x_probe(struct i2c_client *client,
else
formats = SNDRV_PCM_FMTBIT_S16_LE;
tda1997x_audio_dai.capture.formats = formats;
-   ret = snd_soc_register_codec(>client->dev,
+   ret = devm_snd_soc_register_component(>client->dev,
 _codec_driver,
 _audio_dai, 1);
if (ret) {
@@ -2782,7 +2784,6 @@ static int tda1997x_remove(struct i2c_client *client)
struct tda1997x_platform_data *pdata = >pdata;
 
if (pdata->audout_format) {
-   snd_soc_unregister_codec(>dev);
mutex_destroy(>audio_lock);
}
 
-- 
1.9.1

___
Alsa-devel mailing list
alsa-de...@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel


[PATCH v2 3/8] v4l: vsp1: Reset the crop and compose rectangles in the set_fmt helper

2018-04-22 Thread Laurent Pinchart
To make vsp1_subdev_set_pad_format() usable by entities that support
selection rectangles, we need to reset the crop and compose rectangles
when setting the format on the sink pad. Do so and replace the custom
set_fmt implementation of the histogram code by a call to
vsp1_subdev_set_pad_format().

Resetting the crop and compose rectangles for entities that don't
support crop and compose has no adverse effect as the rectangles are
ignored anyway.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_entity.c | 16 +
 drivers/media/platform/vsp1/vsp1_histo.c  | 59 +++
 2 files changed, 20 insertions(+), 55 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_entity.c 
b/drivers/media/platform/vsp1/vsp1_entity.c
index 239df047efd0..181a583aecad 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -335,6 +335,7 @@ int vsp1_subdev_set_pad_format(struct v4l2_subdev *subdev,
struct vsp1_entity *entity = to_vsp1_entity(subdev);
struct v4l2_subdev_pad_config *config;
struct v4l2_mbus_framefmt *format;
+   struct v4l2_rect *selection;
unsigned int i;
int ret = 0;
 
@@ -377,6 +378,21 @@ int vsp1_subdev_set_pad_format(struct v4l2_subdev *subdev,
format = vsp1_entity_get_pad_format(entity, config, 1);
*format = fmt->format;
 
+   /* Reset the crop and compose rectangles */
+   selection = vsp1_entity_get_pad_selection(entity, config, fmt->pad,
+ V4L2_SEL_TGT_CROP);
+   selection->left = 0;
+   selection->top = 0;
+   selection->width = format->width;
+   selection->height = format->height;
+
+   selection = vsp1_entity_get_pad_selection(entity, config, fmt->pad,
+ V4L2_SEL_TGT_COMPOSE);
+   selection->left = 0;
+   selection->top = 0;
+   selection->width = format->width;
+   selection->height = format->height;
+
 done:
mutex_unlock(>lock);
return ret;
diff --git a/drivers/media/platform/vsp1/vsp1_histo.c 
b/drivers/media/platform/vsp1/vsp1_histo.c
index 029181c1fb61..5e15c8ff88d9 100644
--- a/drivers/media/platform/vsp1/vsp1_histo.c
+++ b/drivers/media/platform/vsp1/vsp1_histo.c
@@ -389,65 +389,14 @@ static int histo_set_format(struct v4l2_subdev *subdev,
struct v4l2_subdev_format *fmt)
 {
struct vsp1_histogram *histo = subdev_to_histo(subdev);
-   struct v4l2_subdev_pad_config *config;
-   struct v4l2_mbus_framefmt *format;
-   struct v4l2_rect *selection;
-   unsigned int i;
-   int ret = 0;
 
if (fmt->pad != HISTO_PAD_SINK)
return histo_get_format(subdev, cfg, fmt);
 
-   mutex_lock(>entity.lock);
-
-   config = vsp1_entity_get_pad_config(>entity, cfg, fmt->which);
-   if (!config) {
-   ret = -EINVAL;
-   goto done;
-   }
-
-   /*
-* Default to the first format if the requested format is not
-* supported.
-*/
-   for (i = 0; i < histo->num_formats; ++i) {
-   if (fmt->format.code == histo->formats[i])
-   break;
-   }
-   if (i == histo->num_formats)
-   fmt->format.code = histo->formats[0];
-
-   format = vsp1_entity_get_pad_format(>entity, config, fmt->pad);
-
-   format->code = fmt->format.code;
-   format->width = clamp_t(unsigned int, fmt->format.width,
-   HISTO_MIN_SIZE, HISTO_MAX_SIZE);
-   format->height = clamp_t(unsigned int, fmt->format.height,
-HISTO_MIN_SIZE, HISTO_MAX_SIZE);
-   format->field = V4L2_FIELD_NONE;
-   format->colorspace = V4L2_COLORSPACE_SRGB;
-
-   fmt->format = *format;
-
-   /* Reset the crop and compose rectangles */
-   selection = vsp1_entity_get_pad_selection(>entity, config,
- fmt->pad, V4L2_SEL_TGT_CROP);
-   selection->left = 0;
-   selection->top = 0;
-   selection->width = format->width;
-   selection->height = format->height;
-
-   selection = vsp1_entity_get_pad_selection(>entity, config,
- fmt->pad,
- V4L2_SEL_TGT_COMPOSE);
-   selection->left = 0;
-   selection->top = 0;
-   selection->width = format->width;
-   selection->height = format->height;
-
-done:
-   mutex_unlock(>entity.lock);
-   return ret;
+   return vsp1_subdev_set_pad_format(subdev, cfg, fmt,
+ histo->formats, histo->num_formats,
+ HISTO_MIN_SIZE, HISTO_MIN_SIZE,
+ HISTO_MAX_SIZE, HISTO_MAX_SIZE);
 }
 
 static const struct 

[PATCH v2 4/8] v4l: vsp1: Document the vsp1_du_atomic_config structure

2018-04-22 Thread Laurent Pinchart
The structure is used in the API that the VSP1 driver exposes to the DU
driver. Documenting it is thus important.

Signed-off-by: Laurent Pinchart 
---
Changes since v1:

- Fixed typo
---
 include/media/vsp1.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/media/vsp1.h b/include/media/vsp1.h
index 68a8abe4fac5..ff7ef894465d 100644
--- a/include/media/vsp1.h
+++ b/include/media/vsp1.h
@@ -41,6 +41,16 @@ struct vsp1_du_lif_config {
 int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
  const struct vsp1_du_lif_config *cfg);
 
+/**
+ * struct vsp1_du_atomic_config - VSP atomic configuration parameters
+ * @pixelformat: plane pixel format (V4L2 4CC)
+ * @pitch: line pitch in bytes, for all planes
+ * @mem: DMA memory address for each plane of the frame buffer
+ * @src: source rectangle in the frame buffer (integer coordinates)
+ * @dst: destination rectangle on the display (integer coordinates)
+ * @alpha: alpha value (0: fully transparent, 255: fully opaque)
+ * @zpos: Z position of the plane (from 0 to number of planes minus 1)
+ */
 struct vsp1_du_atomic_config {
u32 pixelformat;
unsigned int pitch;
-- 
Regards,

Laurent Pinchart



[PATCH v2 5/8] v4l: vsp1: Extend the DU API to support CRC computation

2018-04-22 Thread Laurent Pinchart
Add a parameter (in the form of a structure to ease future API
extensions) to the VSP atomic flush handler to pass CRC source
configuration, and pass the CRC value to the completion callback.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c  |  6 --
 drivers/media/platform/vsp1/vsp1_drm.c |  6 --
 drivers/media/platform/vsp1/vsp1_drm.h |  2 +-
 include/media/vsp1.h   | 29 +++--
 4 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 2c260c33840b..bdcec201591f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -31,7 +31,7 @@
 #include "rcar_du_kms.h"
 #include "rcar_du_vsp.h"
 
-static void rcar_du_vsp_complete(void *private, bool completed)
+static void rcar_du_vsp_complete(void *private, bool completed, u32 crc)
 {
struct rcar_du_crtc *crtc = private;
 
@@ -102,7 +102,9 @@ void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc)
 
 void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc)
 {
-   vsp1_du_atomic_flush(crtc->vsp->vsp, crtc->vsp_pipe);
+   struct vsp1_du_atomic_pipe_config cfg = { { 0, } };
+
+   vsp1_du_atomic_flush(crtc->vsp->vsp, crtc->vsp_pipe, );
 }
 
 /* Keep the two tables in sync. */
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
b/drivers/media/platform/vsp1/vsp1_drm.c
index 2b29a83dceb9..5fc31578f9b0 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -36,7 +36,7 @@ static void vsp1_du_pipeline_frame_end(struct vsp1_pipeline 
*pipe,
bool complete = completion == VSP1_DL_FRAME_END_COMPLETED;
 
if (drm_pipe->du_complete)
-   drm_pipe->du_complete(drm_pipe->du_private, complete);
+   drm_pipe->du_complete(drm_pipe->du_private, complete, 0);
 
if (completion & VSP1_DL_FRAME_END_INTERNAL) {
drm_pipe->force_brx_release = false;
@@ -739,8 +739,10 @@ EXPORT_SYMBOL_GPL(vsp1_du_atomic_update);
  * vsp1_du_atomic_flush - Commit an atomic update
  * @dev: the VSP device
  * @pipe_index: the DRM pipeline index
+ * @cfg: atomic pipe configuration
  */
-void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index)
+void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
+ const struct vsp1_du_atomic_pipe_config *cfg)
 {
struct vsp1_device *vsp1 = dev_get_drvdata(dev);
struct vsp1_drm_pipeline *drm_pipe = >drm->pipe[pipe_index];
diff --git a/drivers/media/platform/vsp1/vsp1_drm.h 
b/drivers/media/platform/vsp1/vsp1_drm.h
index f4af1b2b12d6..e5b88b28806c 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.h
+++ b/drivers/media/platform/vsp1/vsp1_drm.h
@@ -35,7 +35,7 @@ struct vsp1_drm_pipeline {
wait_queue_head_t wait_queue;
 
/* Frame synchronisation */
-   void (*du_complete)(void *, bool);
+   void (*du_complete)(void *data, bool completed, u32 crc);
void *du_private;
 };
 
diff --git a/include/media/vsp1.h b/include/media/vsp1.h
index ff7ef894465d..ac63a9928a79 100644
--- a/include/media/vsp1.h
+++ b/include/media/vsp1.h
@@ -34,7 +34,7 @@ struct vsp1_du_lif_config {
unsigned int width;
unsigned int height;
 
-   void (*callback)(void *, bool);
+   void (*callback)(void *data, bool completed, u32 crc);
void *callback_data;
 };
 
@@ -61,11 +61,36 @@ struct vsp1_du_atomic_config {
unsigned int zpos;
 };
 
+/**
+ * enum vsp1_du_crc_source - Source used for CRC calculation
+ * @VSP1_DU_CRC_NONE: CRC calculation disabled
+ * @VSP_DU_CRC_PLANE: Perform CRC calculation on an input plane
+ * @VSP_DU_CRC_OUTPUT: Perform CRC calculation on the composed output
+ */
+enum vsp1_du_crc_source {
+   VSP1_DU_CRC_NONE,
+   VSP1_DU_CRC_PLANE,
+   VSP1_DU_CRC_OUTPUT,
+};
+
+/**
+ * struct vsp1_du_atomic_pipe_config - VSP atomic pipe configuration parameters
+ * @crc.source: source for CRC calculation
+ * @crc.index: index of the CRC source plane (when crc.source is set to plane)
+ */
+struct vsp1_du_atomic_pipe_config {
+   struct  {
+   enum vsp1_du_crc_source source;
+   unsigned int index;
+   } crc;
+};
+
 void vsp1_du_atomic_begin(struct device *dev, unsigned int pipe_index);
 int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
  unsigned int rpf,
  const struct vsp1_du_atomic_config *cfg);
-void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index);
+void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
+ const struct vsp1_du_atomic_pipe_config *cfg);
 int vsp1_du_map_sg(struct device *dev, struct sg_table *sgt);
 void vsp1_du_unmap_sg(struct device *dev, struct sg_table *sgt);
 
-- 
Regards,

Laurent Pinchart



[PATCH v2 8/8] drm: rcar-du: Add support for CRC computation

2018-04-22 Thread Laurent Pinchart
Implement CRC computation configuration and reporting through the DRM
debugfs-based CRC API. The CRC source can be configured to any input
plane or the pipeline output.

Signed-off-by: Laurent Pinchart 
---
Changes since v1:

- Format the source names using plane IDs instead of plane indices
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 156 +++--
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h |  19 
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c  |   7 ++
 3 files changed, 176 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index c4420538ec85..d71d709fe3d9 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -691,6 +691,52 @@ static const struct drm_crtc_helper_funcs 
crtc_helper_funcs = {
.atomic_disable = rcar_du_crtc_atomic_disable,
 };
 
+static struct drm_crtc_state *
+rcar_du_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
+{
+   struct rcar_du_crtc_state *state;
+   struct rcar_du_crtc_state *copy;
+
+   if (WARN_ON(!crtc->state))
+   return NULL;
+
+   state = to_rcar_crtc_state(crtc->state);
+   copy = kmemdup(state, sizeof(*state), GFP_KERNEL);
+   if (copy == NULL)
+   return NULL;
+
+   __drm_atomic_helper_crtc_duplicate_state(crtc, >state);
+
+   return >state;
+}
+
+static void rcar_du_crtc_atomic_destroy_state(struct drm_crtc *crtc,
+ struct drm_crtc_state *state)
+{
+   __drm_atomic_helper_crtc_destroy_state(state);
+   kfree(to_rcar_crtc_state(state));
+}
+
+static void rcar_du_crtc_reset(struct drm_crtc *crtc)
+{
+   struct rcar_du_crtc_state *state;
+
+   if (crtc->state) {
+   rcar_du_crtc_atomic_destroy_state(crtc, crtc->state);
+   crtc->state = NULL;
+   }
+
+   state = kzalloc(sizeof(*state), GFP_KERNEL);
+   if (state == NULL)
+   return;
+
+   state->crc.source = VSP1_DU_CRC_NONE;
+   state->crc.index = 0;
+
+   crtc->state = >state;
+   crtc->state->crtc = crtc;
+}
+
 static int rcar_du_crtc_enable_vblank(struct drm_crtc *crtc)
 {
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
@@ -710,15 +756,111 @@ static void rcar_du_crtc_disable_vblank(struct drm_crtc 
*crtc)
rcrtc->vblank_enable = false;
 }
 
-static const struct drm_crtc_funcs crtc_funcs = {
-   .reset = drm_atomic_helper_crtc_reset,
+static int rcar_du_crtc_set_crc_source(struct drm_crtc *crtc,
+  const char *source_name,
+  size_t *values_cnt)
+{
+   struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
+   struct drm_modeset_acquire_ctx ctx;
+   struct drm_crtc_state *crtc_state;
+   struct drm_atomic_state *state;
+   enum vsp1_du_crc_source source;
+   unsigned int index = 0;
+   unsigned int i;
+   int ret;
+
+   /*
+* Parse the source name. Supported values are "plane%u" to compute the
+* CRC on an input plane (%u is the plane ID), and "auto" to compute the
+* CRC on the composer (VSP) output.
+*/
+   if (!source_name) {
+   source = VSP1_DU_CRC_NONE;
+   } else if (!strcmp(source_name, "auto")) {
+   source = VSP1_DU_CRC_OUTPUT;
+   } else if (strstarts(source_name, "plane")) {
+   source = VSP1_DU_CRC_PLANE;
+
+   ret = kstrtouint(source_name + strlen("plane"), 10, );
+   if (ret < 0)
+   return ret;
+
+   for (i = 0; i < rcrtc->vsp->num_planes; ++i) {
+   if (index == rcrtc->vsp->planes[i].plane.base.id) {
+   index = i;
+   break;
+   }
+   }
+
+   if (i >= rcrtc->vsp->num_planes)
+   return -EINVAL;
+   } else {
+   return -EINVAL;
+   }
+
+   *values_cnt = 1;
+
+   /* Perform an atomic commit to set the CRC source. */
+   drm_modeset_acquire_init(, 0);
+
+   state = drm_atomic_state_alloc(crtc->dev);
+   if (!state) {
+   ret = -ENOMEM;
+   goto unlock;
+   }
+
+   state->acquire_ctx = 
+
+retry:
+   crtc_state = drm_atomic_get_crtc_state(state, crtc);
+   if (!IS_ERR(crtc_state)) {
+   struct rcar_du_crtc_state *rcrtc_state;
+
+   rcrtc_state = to_rcar_crtc_state(crtc_state);
+   rcrtc_state->crc.source = source;
+   rcrtc_state->crc.index = index;
+
+   ret = drm_atomic_commit(state);
+   } else {
+   ret = PTR_ERR(crtc_state);
+   }
+
+   if (ret == -EDEADLK) {
+   drm_atomic_state_clear(state);
+   drm_modeset_backoff();
+   goto retry;
+   }
+
+ 

[PATCH v2 7/8] v4l: vsp1: Integrate DISCOM in display pipeline

2018-04-22 Thread Laurent Pinchart
The DISCOM is used to compute CRCs on display frames. Integrate it in
the display pipeline at the output of the blending unit to process
output frames.

Computing CRCs on input frames is possible by positioning the DISCOM at
a different point in the pipeline. This use case isn't supported at the
moment and could be implemented by extending the API between the VSP1
and DU drivers if needed.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_drm.c | 115 -
 drivers/media/platform/vsp1/vsp1_drm.h |  12 
 2 files changed, 124 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
b/drivers/media/platform/vsp1/vsp1_drm.c
index 5fc31578f9b0..7864b43a90e1 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -22,6 +22,7 @@
 #include "vsp1_lif.h"
 #include "vsp1_pipe.h"
 #include "vsp1_rwpf.h"
+#include "vsp1_uif.h"
 
 #define BRX_NAME(e)(e)->type == VSP1_ENTITY_BRU ? "BRU" : "BRS"
 
@@ -35,8 +36,13 @@ static void vsp1_du_pipeline_frame_end(struct vsp1_pipeline 
*pipe,
struct vsp1_drm_pipeline *drm_pipe = to_vsp1_drm_pipeline(pipe);
bool complete = completion == VSP1_DL_FRAME_END_COMPLETED;
 
-   if (drm_pipe->du_complete)
-   drm_pipe->du_complete(drm_pipe->du_private, complete, 0);
+   if (drm_pipe->du_complete) {
+   struct vsp1_entity *uif = drm_pipe->uif;
+   u32 crc;
+
+   crc = uif ? vsp1_uif_get_crc(to_uif(>subdev)) : 0;
+   drm_pipe->du_complete(drm_pipe->du_private, complete, crc);
+   }
 
if (completion & VSP1_DL_FRAME_END_INTERNAL) {
drm_pipe->force_brx_release = false;
@@ -48,10 +54,65 @@ static void vsp1_du_pipeline_frame_end(struct vsp1_pipeline 
*pipe,
  * Pipeline Configuration
  */
 
+/*
+ * Insert the UIF in the pipeline between the prev and next entities. If no UIF
+ * is available connect the two entities directly.
+ */
+static int vsp1_du_insert_uif(struct vsp1_device *vsp1,
+ struct vsp1_pipeline *pipe,
+ struct vsp1_entity *uif,
+ struct vsp1_entity *prev, unsigned int prev_pad,
+ struct vsp1_entity *next, unsigned int next_pad)
+{
+   int ret;
+
+   if (uif) {
+   struct v4l2_subdev_format format;
+
+   prev->sink = uif;
+   prev->sink_pad = UIF_PAD_SINK;
+
+   memset(, 0, sizeof(format));
+   format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+   format.pad = prev_pad;
+
+   ret = v4l2_subdev_call(>subdev, pad, get_fmt, NULL,
+  );
+   if (ret < 0)
+   return ret;
+
+   format.pad = UIF_PAD_SINK;
+
+   ret = v4l2_subdev_call(>subdev, pad, set_fmt, NULL,
+  );
+   if (ret < 0)
+   return ret;
+
+   dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on UIF sink\n",
+   __func__, format.format.width, format.format.height,
+   format.format.code);
+
+   /*
+* The UIF doesn't mangle the format between its sink and
+* source pads, so there is no need to retrieve the format on
+* its source pad.
+*/
+
+   uif->sink = next;
+   uif->sink_pad = next_pad;
+   } else {
+   prev->sink = next;
+   prev->sink_pad = next_pad;
+   }
+
+   return 0;
+}
+
 /* Setup one RPF and the connected BRx sink pad. */
 static int vsp1_du_pipeline_setup_rpf(struct vsp1_device *vsp1,
  struct vsp1_pipeline *pipe,
  struct vsp1_rwpf *rpf,
+ struct vsp1_entity *uif,
  unsigned int brx_input)
 {
struct v4l2_subdev_selection sel;
@@ -122,6 +183,12 @@ static int vsp1_du_pipeline_setup_rpf(struct vsp1_device 
*vsp1,
if (ret < 0)
return ret;
 
+   /* Insert and configure the UIF if available. */
+   ret = vsp1_du_insert_uif(vsp1, pipe, uif, >entity, RWPF_PAD_SOURCE,
+pipe->brx, brx_input);
+   if (ret < 0)
+   return ret;
+
/* BRx sink, propagate the format from the RPF source. */
format.pad = brx_input;
 
@@ -297,7 +364,10 @@ static unsigned int rpf_zpos(struct vsp1_device *vsp1, 
struct vsp1_rwpf *rpf)
 static int vsp1_du_pipeline_setup_inputs(struct vsp1_device *vsp1,
struct vsp1_pipeline *pipe)
 {
+   struct vsp1_drm_pipeline *drm_pipe = to_vsp1_drm_pipeline(pipe);
struct vsp1_rwpf *inputs[VSP1_MAX_RPF] = { NULL, 

[PATCH v2 1/8] v4l: vsp1: Use SPDX license headers

2018-04-22 Thread Laurent Pinchart
Adopt the SPDX license identifier headers to ease license compliance
management. All files in the driver are licensed under the GPLv2+ except
for the vsp1_regs.h file which is licensed under the GPLv2. This is
likely an oversight, but fixing this requires contacting the copyright
owners and is out of scope for this patch.

While at it fix the file descriptions to match file names where copy and
paste error occurred.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1.h| 6 +-
 drivers/media/platform/vsp1/vsp1_brx.c| 6 +-
 drivers/media/platform/vsp1/vsp1_brx.h| 6 +-
 drivers/media/platform/vsp1/vsp1_clu.c| 6 +-
 drivers/media/platform/vsp1/vsp1_clu.h| 6 +-
 drivers/media/platform/vsp1/vsp1_dl.c | 8 ++--
 drivers/media/platform/vsp1/vsp1_dl.h | 6 +-
 drivers/media/platform/vsp1/vsp1_drm.c| 8 ++--
 drivers/media/platform/vsp1/vsp1_drm.h| 6 +-
 drivers/media/platform/vsp1/vsp1_drv.c| 6 +-
 drivers/media/platform/vsp1/vsp1_entity.c | 6 +-
 drivers/media/platform/vsp1/vsp1_entity.h | 6 +-
 drivers/media/platform/vsp1/vsp1_hgo.c| 6 +-
 drivers/media/platform/vsp1/vsp1_hgo.h| 6 +-
 drivers/media/platform/vsp1/vsp1_hgt.c| 6 +-
 drivers/media/platform/vsp1/vsp1_hgt.h| 6 +-
 drivers/media/platform/vsp1/vsp1_histo.c  | 6 +-
 drivers/media/platform/vsp1/vsp1_histo.h  | 6 +-
 drivers/media/platform/vsp1/vsp1_hsit.c   | 6 +-
 drivers/media/platform/vsp1/vsp1_hsit.h   | 6 +-
 drivers/media/platform/vsp1/vsp1_lif.c| 6 +-
 drivers/media/platform/vsp1/vsp1_lif.h| 6 +-
 drivers/media/platform/vsp1/vsp1_lut.c| 6 +-
 drivers/media/platform/vsp1/vsp1_lut.h| 6 +-
 drivers/media/platform/vsp1/vsp1_pipe.c   | 6 +-
 drivers/media/platform/vsp1/vsp1_pipe.h   | 6 +-
 drivers/media/platform/vsp1/vsp1_regs.h   | 5 +
 drivers/media/platform/vsp1/vsp1_rpf.c| 6 +-
 drivers/media/platform/vsp1/vsp1_rwpf.c   | 6 +-
 drivers/media/platform/vsp1/vsp1_rwpf.h   | 6 +-
 drivers/media/platform/vsp1/vsp1_sru.c| 6 +-
 drivers/media/platform/vsp1/vsp1_sru.h| 6 +-
 drivers/media/platform/vsp1/vsp1_uds.c| 6 +-
 drivers/media/platform/vsp1/vsp1_uds.h| 6 +-
 drivers/media/platform/vsp1/vsp1_video.c  | 6 +-
 drivers/media/platform/vsp1/vsp1_video.h  | 6 +-
 drivers/media/platform/vsp1/vsp1_wpf.c| 6 +-
 37 files changed, 39 insertions(+), 186 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 894cc725c2d4..9cf4e1c4b036 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -1,14 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * vsp1.h  --  R-Car VSP1 Driver
  *
  * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinch...@ideasonboard.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
  */
 #ifndef __VSP1_H__
 #define __VSP1_H__
diff --git a/drivers/media/platform/vsp1/vsp1_brx.c 
b/drivers/media/platform/vsp1/vsp1_brx.c
index b4af1d546022..3beec18fd863 100644
--- a/drivers/media/platform/vsp1/vsp1_brx.c
+++ b/drivers/media/platform/vsp1/vsp1_brx.c
@@ -1,14 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * vsp1_brx.c  --  R-Car VSP1 Blend ROP Unit (BRU and BRS)
  *
  * Copyright (C) 2013 Renesas Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinch...@ideasonboard.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
  */
 
 #include 
diff --git a/drivers/media/platform/vsp1/vsp1_brx.h 
b/drivers/media/platform/vsp1/vsp1_brx.h
index 927aa4254c0f..6abbb8c3343c 100644
--- a/drivers/media/platform/vsp1/vsp1_brx.h
+++ b/drivers/media/platform/vsp1/vsp1_brx.h
@@ -1,14 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * vsp1_brx.h  --  R-Car VSP1 Blend ROP Unit (BRU and BRS)
  *
  * Copyright (C) 2013 Renesas Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinch...@ideasonboard.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
  */
 #ifndef __VSP1_BRX_H__
 #define __VSP1_BRX_H__
diff --git a/drivers/media/platform/vsp1/vsp1_clu.c 
b/drivers/media/platform/vsp1/vsp1_clu.c
index f2fb26e5ab4e..9626b6308585 100644
--- a/drivers/media/platform/vsp1/vsp1_clu.c

[PATCH v2 0/8] R-Car DU: Support CRC calculation

2018-04-22 Thread Laurent Pinchart
Hello,

This patch series adds support for CRC calculation to the rcar-du-drm driver.

CRC calculation is supported starting at the Renesas R-Car Gen3 SoCs, as
earlier versions don't have the necessary hardware. On Gen3 SoCs, the CRC is
computed by the DISCOM module part of the VSP-D and VSP-DL.

The DISCOM is interfaced to the VSP through the UIF glue and appears as a VSP
entity with a sink pad and a source pad.

The series starts with a switch to SPDX license headers in patch 1/8, prompted
by a checkpatch.pl warning for a later patch that complained about missing
SPDX license headers. It then continues with cleanup and refactoring. Patches
2/8 and 3/8 prepare for DISCOM and UIF support by extending generic code to
make it usable for the UIF. Patch 4/8 documents a structure that will receive
new fields.

Patch 5/8 then extends the API exposed by the VSP driver to the DU driver to
support CRC computation configuration and reporting. The patch unfortunately
needs to touch both the VSP and DU drivers, so the whole series will need to
be merged through a single tree.

Patch 5/8 adds support for the DISCOM and UIF in the VSP driver, patch 7/8
integrates it in the DRM pipeline, and patch 8/8 finally implements the CRC
API in the DU driver to expose CRC computation to userspace.

The hardware supports computing the CRC at any arbitrary point in the
pipeline on a configurable window of the frame. This patch series supports CRC
computation on input planes or pipeline output, but on the full frame only.
Support for CRC window configuration can be added later if needed but will
require extending the userspace API, as the DRM/KMS CRC API doesn't support
this feature.

Compared to v1, the CRC source names for plane inputs are now constructed from
plane IDs instead of plane indices. This allows userspace to match CRC sources
with planes.

Note that exposing the DISCOM and UIF though the V4L2 API isn't supported as
the module is only found in VSP-D and VSP-DL instances that are not exposed
through V4L2. It is possible to expose those instances through V4L2 with a
small modification to the driver for testing purpose. If the need arises to
test DISCOM and UIF with such an out-of-tree patch, support for CRC reporting
through a V4L2 control can be added later without affecting how CRC is exposed
through the DRM/KMS API.

The patches are based on top of the "[PATCH v2 00/15] R-Car VSP1: Dynamically
assign blend units to display pipelines" patch series, itself based on top of
the Linux media master branch and scheduled for merge in v4.18. The new base
caused heavy conflicts, requiring this series to be merged through the V4L2
tree. Once the patches receive the necessary review I will ask Dave to ack the
merge plan.

For convenience the patches are available at

git://linuxtv.org/pinchartl/media.git vsp1-discom-v2-20180423

The code has been tested through the kms-test-crc.py script part of the DU
test suite available at

git://git.ideasonboard.com/renesas/kms-tests.git discom

Laurent Pinchart (8):
  v4l: vsp1: Use SPDX license headers
  v4l: vsp1: Share the CLU, LIF and LUT set_fmt pad operation code
  v4l: vsp1: Reset the crop and compose rectangles in the set_fmt helper
  v4l: vsp1: Document the vsp1_du_atomic_config structure
  v4l: vsp1: Extend the DU API to support CRC computation
  v4l: vsp1: Add support for the DISCOM entity
  v4l: vsp1: Integrate DISCOM in display pipeline
  drm: rcar-du: Add support for CRC computation

 drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 156 -
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h|  19 +++
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c |  13 +-
 drivers/media/platform/vsp1/Makefile  |   2 +-
 drivers/media/platform/vsp1/vsp1.h|  10 +-
 drivers/media/platform/vsp1/vsp1_brx.c|   6 +-
 drivers/media/platform/vsp1/vsp1_brx.h|   6 +-
 drivers/media/platform/vsp1/vsp1_clu.c|  71 ++--
 drivers/media/platform/vsp1/vsp1_clu.h|   6 +-
 drivers/media/platform/vsp1/vsp1_dl.c |   8 +-
 drivers/media/platform/vsp1/vsp1_dl.h |   6 +-
 drivers/media/platform/vsp1/vsp1_drm.c| 127 --
 drivers/media/platform/vsp1/vsp1_drm.h|  20 ++-
 drivers/media/platform/vsp1/vsp1_drv.c|  26 ++-
 drivers/media/platform/vsp1/vsp1_entity.c | 103 +++-
 drivers/media/platform/vsp1/vsp1_entity.h |  13 +-
 drivers/media/platform/vsp1/vsp1_hgo.c|   6 +-
 drivers/media/platform/vsp1/vsp1_hgo.h|   6 +-
 drivers/media/platform/vsp1/vsp1_hgt.c|   6 +-
 drivers/media/platform/vsp1/vsp1_hgt.h|   6 +-
 drivers/media/platform/vsp1/vsp1_histo.c  |  65 +--
 drivers/media/platform/vsp1/vsp1_histo.h  |   6 +-
 drivers/media/platform/vsp1/vsp1_hsit.c   |   6 +-
 drivers/media/platform/vsp1/vsp1_hsit.h   |   6 +-
 drivers/media/platform/vsp1/vsp1_lif.c|  71 ++--
 drivers/media/platform/vsp1/vsp1_lif.h|   6 +-
 drivers/media/platform/vsp1/vsp1_lut.c|  71 ++--
 drivers/media/platform/vsp1/vsp1_lut.h   

[PATCH v2 6/8] v4l: vsp1: Add support for the DISCOM entity

2018-04-22 Thread Laurent Pinchart
The DISCOM calculates a CRC on a configurable window of the frame. It
interfaces to the VSP through the UIF glue, hence the name used in the
code.

The module supports configuration of the CRC window through the crop
rectangle on the ink pad of the corresponding entity. However, unlike
the traditional V4L2 subdevice model, the crop rectangle does not
influence the format on the source pad.

Modeling the DISCOM as a sink-only entity would allow adhering to the
V4L2 subdevice model at the expense of more complex code in the driver,
as at the hardware level the UIF is handled as a sink+source entity. As
the DISCOM is only present in R-Car Gen3 VSP-D and VSP-DL instances it
is not exposed to userspace through V4L2 but controlled through the DU
driver. We can thus change this model later if needed without fear of
affecting userspace.

Signed-off-by: Laurent Pinchart 
---
Changes since v1:

- Don't return uninitialized value from uif_set_selection()
---
 drivers/media/platform/vsp1/Makefile  |   2 +-
 drivers/media/platform/vsp1/vsp1.h|   4 +
 drivers/media/platform/vsp1/vsp1_drv.c|  20 +++
 drivers/media/platform/vsp1/vsp1_entity.c |   6 +
 drivers/media/platform/vsp1/vsp1_entity.h |   1 +
 drivers/media/platform/vsp1/vsp1_regs.h   |  41 +
 drivers/media/platform/vsp1/vsp1_uif.c| 271 ++
 drivers/media/platform/vsp1/vsp1_uif.h|  32 
 8 files changed, 376 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/vsp1/vsp1_uif.c
 create mode 100644 drivers/media/platform/vsp1/vsp1_uif.h

diff --git a/drivers/media/platform/vsp1/Makefile 
b/drivers/media/platform/vsp1/Makefile
index 596775f932c0..4bb4dcbef7b5 100644
--- a/drivers/media/platform/vsp1/Makefile
+++ b/drivers/media/platform/vsp1/Makefile
@@ -5,6 +5,6 @@ vsp1-y  += vsp1_rpf.o 
vsp1_rwpf.o vsp1_wpf.o
 vsp1-y += vsp1_clu.o vsp1_hsit.o vsp1_lut.o
 vsp1-y += vsp1_brx.o vsp1_sru.o vsp1_uds.o
 vsp1-y += vsp1_hgo.o vsp1_hgt.o vsp1_histo.o
-vsp1-y += vsp1_lif.o
+vsp1-y += vsp1_lif.o vsp1_uif.o
 
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1.o
diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 9cf4e1c4b036..33f632331474 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -36,10 +36,12 @@ struct vsp1_lut;
 struct vsp1_rwpf;
 struct vsp1_sru;
 struct vsp1_uds;
+struct vsp1_uif;
 
 #define VSP1_MAX_LIF   2
 #define VSP1_MAX_RPF   5
 #define VSP1_MAX_UDS   3
+#define VSP1_MAX_UIF   2
 #define VSP1_MAX_WPF   4
 
 #define VSP1_HAS_LUT   (1 << 1)
@@ -60,6 +62,7 @@ struct vsp1_device_info {
unsigned int lif_count;
unsigned int rpf_count;
unsigned int uds_count;
+   unsigned int uif_count;
unsigned int wpf_count;
unsigned int num_bru_inputs;
bool uapi;
@@ -86,6 +89,7 @@ struct vsp1_device {
struct vsp1_rwpf *rpf[VSP1_MAX_RPF];
struct vsp1_sru *sru;
struct vsp1_uds *uds[VSP1_MAX_UDS];
+   struct vsp1_uif *uif[VSP1_MAX_UIF];
struct vsp1_rwpf *wpf[VSP1_MAX_WPF];
 
struct list_head entities;
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c 
b/drivers/media/platform/vsp1/vsp1_drv.c
index 331a2e0af0d3..d29f9c4baebe 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -35,6 +35,7 @@
 #include "vsp1_rwpf.h"
 #include "vsp1_sru.h"
 #include "vsp1_uds.h"
+#include "vsp1_uif.h"
 #include "vsp1_video.h"
 
 /* 
-
@@ -409,6 +410,19 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
list_add_tail(>entity.list_dev, >entities);
}
 
+   for (i = 0; i < vsp1->info->uif_count; ++i) {
+   struct vsp1_uif *uif;
+
+   uif = vsp1_uif_create(vsp1, i);
+   if (IS_ERR(uif)) {
+   ret = PTR_ERR(uif);
+   goto done;
+   }
+
+   vsp1->uif[i] = uif;
+   list_add_tail(>entity.list_dev, >entities);
+   }
+
for (i = 0; i < vsp1->info->wpf_count; ++i) {
struct vsp1_rwpf *wpf;
 
@@ -513,6 +527,9 @@ static int vsp1_device_init(struct vsp1_device *vsp1)
for (i = 0; i < vsp1->info->uds_count; ++i)
vsp1_write(vsp1, VI6_DPR_UDS_ROUTE(i), VI6_DPR_NODE_UNUSED);
 
+   for (i = 0; i < vsp1->info->uif_count; ++i)
+   vsp1_write(vsp1, VI6_DPR_UIF_ROUTE(i), VI6_DPR_NODE_UNUSED);
+
vsp1_write(vsp1, VI6_DPR_SRU_ROUTE, VI6_DPR_NODE_UNUSED);
vsp1_write(vsp1, VI6_DPR_LUT_ROUTE, VI6_DPR_NODE_UNUSED);
vsp1_write(vsp1, VI6_DPR_CLU_ROUTE, 

[PATCH v2 2/8] v4l: vsp1: Share the CLU, LIF and LUT set_fmt pad operation code

2018-04-22 Thread Laurent Pinchart
The implementation of the set_fmt pad operation is identical in the
three modules. Move it to a generic helper function.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_clu.c| 65 +--
 drivers/media/platform/vsp1/vsp1_entity.c | 75 +++
 drivers/media/platform/vsp1/vsp1_entity.h |  6 +++
 drivers/media/platform/vsp1/vsp1_lif.c| 65 +--
 drivers/media/platform/vsp1/vsp1_lut.c| 65 +--
 5 files changed, 116 insertions(+), 160 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_clu.c 
b/drivers/media/platform/vsp1/vsp1_clu.c
index 9626b6308585..96a448e1504c 100644
--- a/drivers/media/platform/vsp1/vsp1_clu.c
+++ b/drivers/media/platform/vsp1/vsp1_clu.c
@@ -114,18 +114,18 @@ static const struct v4l2_ctrl_config clu_mode_control = {
  * V4L2 Subdevice Pad Operations
  */
 
+static const unsigned int clu_codes[] = {
+   MEDIA_BUS_FMT_ARGB_1X32,
+   MEDIA_BUS_FMT_AHSV_1X32,
+   MEDIA_BUS_FMT_AYUV8_1X32,
+};
+
 static int clu_enum_mbus_code(struct v4l2_subdev *subdev,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_mbus_code_enum *code)
 {
-   static const unsigned int codes[] = {
-   MEDIA_BUS_FMT_ARGB_1X32,
-   MEDIA_BUS_FMT_AHSV_1X32,
-   MEDIA_BUS_FMT_AYUV8_1X32,
-   };
-
-   return vsp1_subdev_enum_mbus_code(subdev, cfg, code, codes,
- ARRAY_SIZE(codes));
+   return vsp1_subdev_enum_mbus_code(subdev, cfg, code, clu_codes,
+ ARRAY_SIZE(clu_codes));
 }
 
 static int clu_enum_frame_size(struct v4l2_subdev *subdev,
@@ -141,51 +141,10 @@ static int clu_set_format(struct v4l2_subdev *subdev,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_format *fmt)
 {
-   struct vsp1_clu *clu = to_clu(subdev);
-   struct v4l2_subdev_pad_config *config;
-   struct v4l2_mbus_framefmt *format;
-   int ret = 0;
-
-   mutex_lock(>entity.lock);
-
-   config = vsp1_entity_get_pad_config(>entity, cfg, fmt->which);
-   if (!config) {
-   ret = -EINVAL;
-   goto done;
-   }
-
-   /* Default to YUV if the requested format is not supported. */
-   if (fmt->format.code != MEDIA_BUS_FMT_ARGB_1X32 &&
-   fmt->format.code != MEDIA_BUS_FMT_AHSV_1X32 &&
-   fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32)
-   fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32;
-
-   format = vsp1_entity_get_pad_format(>entity, config, fmt->pad);
-
-   if (fmt->pad == CLU_PAD_SOURCE) {
-   /* The CLU output format can't be modified. */
-   fmt->format = *format;
-   goto done;
-   }
-
-   format->code = fmt->format.code;
-   format->width = clamp_t(unsigned int, fmt->format.width,
-   CLU_MIN_SIZE, CLU_MAX_SIZE);
-   format->height = clamp_t(unsigned int, fmt->format.height,
-CLU_MIN_SIZE, CLU_MAX_SIZE);
-   format->field = V4L2_FIELD_NONE;
-   format->colorspace = V4L2_COLORSPACE_SRGB;
-
-   fmt->format = *format;
-
-   /* Propagate the format to the source pad. */
-   format = vsp1_entity_get_pad_format(>entity, config,
-   CLU_PAD_SOURCE);
-   *format = fmt->format;
-
-done:
-   mutex_unlock(>entity.lock);
-   return ret;
+   return vsp1_subdev_set_pad_format(subdev, cfg, fmt, clu_codes,
+ ARRAY_SIZE(clu_codes),
+ CLU_MIN_SIZE, CLU_MIN_SIZE,
+ CLU_MAX_SIZE, CLU_MAX_SIZE);
 }
 
 /* 
-
diff --git a/drivers/media/platform/vsp1/vsp1_entity.c 
b/drivers/media/platform/vsp1/vsp1_entity.c
index 72354caf5746..239df047efd0 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -307,6 +307,81 @@ int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
return ret;
 }
 
+/*
+ * vsp1_subdev_set_pad_format - Subdev pad set_fmt handler
+ * @subdev: V4L2 subdevice
+ * @cfg: V4L2 subdev pad configuration
+ * @fmt: V4L2 subdev format
+ * @codes: Array of supported media bus codes
+ * @ncodes: Number of supported media bus codes
+ * @min_width: Minimum image width
+ * @min_height: Minimum image height
+ * @max_width: Maximum image width
+ * @max_height: Maximum image height
+ *
+ * This function implements the subdev set_fmt pad operation for entities that
+ * do not support scaling or cropping. It defaults to the first supplied media
+ * bus code if the requested code isn't supported, 

Re: [PATCH 1/1] media: rc: Add NVIDIA IR keymapping

2018-04-22 Thread kbuild test robot
Hi Jun,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.17-rc1 next-20180420]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Vladislav-Zhurba/media-rc-Add-NVIDIA-IR-keymapping/20180423-023840
base:   git://linuxtv.org/media_tree.git master
config: i386-randconfig-s1-201816 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

>> drivers/media/rc/keymaps/rc-nvidia.c:47:4: error: unknown field 'rc_type' 
>> specified in initializer
   .rc_type = RC_TYPE_SONY12,
   ^
>> drivers/media/rc/keymaps/rc-nvidia.c:47:15: error: 'RC_TYPE_SONY12' 
>> undeclared here (not in a function)
   .rc_type = RC_TYPE_SONY12,
  ^~
--
>> drivers/media/rc/keymaps/rc-nvidia-nec.c:47:4: error: unknown field 
>> 'rc_type' specified in initializer
   .rc_type = RC_TYPE_NEC,
   ^
>> drivers/media/rc/keymaps/rc-nvidia-nec.c:47:15: error: 'RC_TYPE_NEC' 
>> undeclared here (not in a function)
   .rc_type = RC_TYPE_NEC,
  ^~~

vim +/rc_type +47 drivers/media/rc/keymaps/rc-nvidia.c

42  
43  static struct rc_map_list nvidia_map = {
44  .map = {
45  .scan = foster_table,
46  .size = ARRAY_SIZE(foster_table),
  > 47  .rc_type = RC_TYPE_SONY12,
48  .name = RC_MAP_NVIDIA,
49  }
50  };
51  

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


.config.gz
Description: application/gzip


Re: [PATCH 1/1] media: rc: Add NVIDIA IR keymapping

2018-04-22 Thread kbuild test robot
Hi Jun,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.17-rc1 next-20180420]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Vladislav-Zhurba/media-rc-Add-NVIDIA-IR-keymapping/20180423-023840
base:   git://linuxtv.org/media_tree.git master
config: x86_64-allyesdebian (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> drivers/media/rc/keymaps/rc-nvidia.c:47:5: error: 'struct rc_map' has no 
>> member named 'rc_type'
   .rc_type = RC_TYPE_SONY12,
^~~
>> drivers/media/rc/keymaps/rc-nvidia.c:47:15: error: 'RC_TYPE_SONY12' 
>> undeclared here (not in a function); did you mean 'RC_PROTO_SONY12'?
   .rc_type = RC_TYPE_SONY12,
  ^~
  RC_PROTO_SONY12
--
>> drivers/media/rc/keymaps/rc-nvidia-nec.c:47:5: error: 'struct rc_map' has no 
>> member named 'rc_type'
   .rc_type = RC_TYPE_NEC,
^~~
>> drivers/media/rc/keymaps/rc-nvidia-nec.c:47:15: error: 'RC_TYPE_NEC' 
>> undeclared here (not in a function); did you mean 'RC_MAP_CEC'?
   .rc_type = RC_TYPE_NEC,
  ^~~
  RC_MAP_CEC

vim +47 drivers/media/rc/keymaps/rc-nvidia.c

42  
43  static struct rc_map_list nvidia_map = {
44  .map = {
45  .scan = foster_table,
46  .size = ARRAY_SIZE(foster_table),
  > 47  .rc_type = RC_TYPE_SONY12,
48  .name = RC_MAP_NVIDIA,
49  }
50  };
51  

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


.config.gz
Description: application/gzip


Re: [PATCH 6/8] drm: rcar-du: rcar-lvds: Add bridge format support

2018-04-22 Thread Peter Rosin
On 2018-04-19 11:31, Jacopo Mondi wrote:
> With the introduction of static input image format enumeration in DRM
> bridges, add support to retrieve the format in rcar-lvds LVDS encoder
> from both panel or bridge, to set the desired LVDS mode.
> 
> Do not rely on 'DRM_BUS_FLAG_DATA_LSB_TO_MSB' flag to mirror the LVDS
> format, as it is only defined for drm connectors, but use the newly
> introduced _LE version of LVDS mbus image formats.
> 
> Signed-off-by: Jacopo Mondi 
> ---
>  drivers/gpu/drm/rcar-du/rcar_lvds.c | 64 
> +
>  1 file changed, 44 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c 
> b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> index 3d2d3bb..2fa875f 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> @@ -280,41 +280,65 @@ static bool rcar_lvds_mode_fixup(struct drm_bridge 
> *bridge,
>   return true;
>  }
>  
> -static void rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds)
> +static int rcar_lvds_get_lvds_mode_from_connector(struct rcar_lvds *lvds,
> +   unsigned int *bus_fmt)
>  {
>   struct drm_display_info *info = >connector.display_info;
> - enum rcar_lvds_mode mode;
> -
> - /*
> -  * There is no API yet to retrieve LVDS mode from a bridge, only panels
> -  * are supported.
> -  */
> - if (!lvds->panel)
> - return;
>  
>   if (!info->num_bus_formats || !info->bus_formats) {
>   dev_err(lvds->dev, "no LVDS bus format reported\n");
> - return;
> + return -EINVAL;
> + }
> +
> + *bus_fmt = info->bus_formats[0];
> +
> + return 0;
> +}
> +
> +static int rcar_lvds_get_lvds_mode_from_bridge(struct rcar_lvds *lvds,
> +unsigned int *bus_fmt)
> +{
> + if (!lvds->next_bridge->num_bus_formats ||
> + !lvds->next_bridge->bus_formats) {
> + dev_err(lvds->dev, "no LVDS bus format reported\n");
> + return -EINVAL;
>   }
>  
> - switch (info->bus_formats[0]) {
> + *bus_fmt = lvds->next_bridge->bus_formats[0];

What makes the first reported format the best choice?

> +
> + return 0;
> +}
> +
> +static void rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds)
> +{
> + unsigned int bus_fmt;
> + int ret;
> +
> + if (lvds->panel)
> + ret = rcar_lvds_get_lvds_mode_from_connector(lvds, _fmt);
> + else
> + ret = rcar_lvds_get_lvds_mode_from_bridge(lvds, _fmt);

What if no bridge reports any format, shouldn't the connector be examined
then?

> + if (ret)
> + return;
> +
> + switch (bus_fmt) {
> + case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG_LE:
> + case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA_LE:
> + lvds->mode |= RCAR_LVDS_MODE_MIRROR;
>   case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
>   case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
> - mode = RCAR_LVDS_MODE_JEIDA;
> + lvds->mode = RCAR_LVDS_MODE_JEIDA;

This is b0rken, first the mirror bit is ORed into some unknown preexisting
value, then the code falls through (without any fall through comment, btw)
and forcibly sets the mode, thus discarding the mirror bit which was
carefully ORed in.

>   break;
> +
> + case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG_LE:
> + lvds->mode |= RCAR_LVDS_MODE_MIRROR;
>   case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
> - mode = RCAR_LVDS_MODE_VESA;
> + lvds->mode = RCAR_LVDS_MODE_VESA;

Dito.

Cheers,
Peter

>   break;
>   default:
>   dev_err(lvds->dev, "unsupported LVDS bus format 0x%04x\n",
> - info->bus_formats[0]);
> - return;
> + bus_fmt);
>   }
> -
> - if (info->bus_flags & DRM_BUS_FLAG_DATA_LSB_TO_MSB)
> - mode |= RCAR_LVDS_MODE_MIRROR;
> -
> - lvds->mode = mode;
>  }
>  
>  static void rcar_lvds_mode_set(struct drm_bridge *bridge,
> 



Re: [PATCH 2/8] dt-bindings: display: bridge: thc63lvd1024: Add lvds map property

2018-04-22 Thread Peter Rosin
On 2018-04-19 11:31, Jacopo Mondi wrote:
> The THC63LVD1024 LVDS to RGB bridge supports two different input mapping
> modes, selectable by means of an external pin.
> 
> Describe the LVDS mode map through a newly defined mandatory property in
> device tree bindings.
> 
> Signed-off-by: Jacopo Mondi 
> ---
>  .../devicetree/bindings/display/bridge/thine,thc63lvd1024.txt  | 3 
> +++
>  1 file changed, 3 insertions(+)
> 
> diff --git 
> a/Documentation/devicetree/bindings/display/bridge/thine,thc63lvd1024.txt 
> b/Documentation/devicetree/bindings/display/bridge/thine,thc63lvd1024.txt
> index 37f0c04..0937595 100644
> --- a/Documentation/devicetree/bindings/display/bridge/thine,thc63lvd1024.txt
> +++ b/Documentation/devicetree/bindings/display/bridge/thine,thc63lvd1024.txt
> @@ -12,6 +12,8 @@ Required properties:
>  - compatible: Shall be "thine,thc63lvd1024"
>  - vcc-supply: Power supply for TTL output, TTL CLOCKOUT signal, LVDS input,
>PPL and digital circuitry
> +- thine,map: LVDS mapping mode selection signal, pin name "MAP". Shall be <1>
> +  for mapping mode 1, <0> for mapping mode 2

Since the MAP pin is an input pin, I would expect there to be an optional gpio
specifier like thine,map-gpios so that the driver can set it according to
the value given in thine,map in case the HW has a line from some gpio output
to the MAP pin (instead of hardwired hi/low which seem to be your thinking).

Cheers,
Peter

>  
>  Optional properties:
>  - powerdown-gpios: Power down GPIO signal, pin name "/PDWN". Active low
> @@ -36,6 +38,7 @@ Example:
>  
>   vcc-supply = <_lvds_vcc>;
>   powerdown-gpios = < 15 GPIO_ACTIVE_LOW>;
> + thine,map = <1>;
>  
>   ports {
>   #address-cells = <1>;
> 



Re: [PATCH 3/8] drm: bridge: thc63lvd1024: Add support for LVDS mode map

2018-04-22 Thread Peter Rosin
On 2018-04-19 11:31, Jacopo Mondi wrote:
> The THC63LVD1024 LVDS to RGB bridge supports two different LVDS mapping
> modes, selectable by means of an external pin.
> 
> Add support for configurable LVDS input mapping modes, using the newly
> introduced support for bridge input image formats.
> 
> Signed-off-by: Jacopo Mondi 
> ---
>  drivers/gpu/drm/bridge/thc63lvd1024.c | 41 
> +++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c 
> b/drivers/gpu/drm/bridge/thc63lvd1024.c
> index 48527f8..a3071a1 100644
> --- a/drivers/gpu/drm/bridge/thc63lvd1024.c
> +++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
> @@ -10,9 +10,15 @@
>  #include 
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  
> +enum thc63_lvds_mapping_mode {
> + THC63_LVDS_MAP_MODE2,
> + THC63_LVDS_MAP_MODE1,
> +};
> +
>  enum thc63_ports {
>   THC63_LVDS_IN0,
>   THC63_LVDS_IN1,
> @@ -116,6 +122,37 @@ static int thc63_parse_dt(struct thc63_dev *thc63)
>   return 0;
>  }
>  
> +static int thc63_set_bus_fmt(struct thc63_dev *thc63)
> +{
> + u32 bus_fmt;
> + u32 map;
> + int ret;
> +
> + ret = of_property_read_u32(thc63->dev->of_node, "thine,map", );
> + if (ret) {
> + dev_err(thc63->dev,
> + "Unable to parse property \"thine,map\": %d\n", ret);
> + return ret;
> + }
> +
> + switch (map) {
> + case THC63_LVDS_MAP_MODE1:
> + bus_fmt = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
> + break;
> + case THC63_LVDS_MAP_MODE2:
> + bus_fmt = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;

Why do you assume rgb888/1x7x4 here? It might as well be rgb666/1x7x3
or rgb101010/1x7x5, no?

Cheers,
Peter

> + break;
> + default:
> + dev_err(thc63->dev,
> + "Invalid value for property \"thine,map\": %u\n", map);
> + return -EINVAL;
> + }
> +
> + drm_bridge_set_bus_formats(>bridge, _fmt, 1);
> +
> + return 0;
> +}
> +
>  static int thc63_gpio_init(struct thc63_dev *thc63)
>  {
>   thc63->oe = devm_gpiod_get_optional(thc63->dev, "oe", GPIOD_OUT_LOW);
> @@ -166,6 +203,10 @@ static int thc63_probe(struct platform_device *pdev)
>   if (ret)
>   return ret;
>  
> + ret = thc63_set_bus_fmt(thc63);
> + if (ret)
> + return ret;
> +
>   thc63->bridge.driver_private = thc63;
>   thc63->bridge.of_node = pdev->dev.of_node;
>   thc63->bridge.funcs = _bridge_func;
> 



Re: [PATCH 1/8] drm: bridge: Add support for static image formats

2018-04-22 Thread Peter Rosin
On 2018-04-19 11:31, Jacopo Mondi wrote:
> Add support for storing image format information in DRM bridges with
> associated helper function.
> 
> This patch replicates for bridges what 'drm_display_info_set_bus_formats()'
> is for connectors.
> 
> Signed-off-by: Jacopo Mondi 
> ---
>  drivers/gpu/drm/drm_bridge.c | 30 ++
>  include/drm/drm_bridge.h |  8 
>  2 files changed, 38 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 1638bfe..e2ad098 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -157,6 +157,36 @@ void drm_bridge_detach(struct drm_bridge *bridge)
>  }
>  
>  /**
> + * drm_bridge_set_bus_formats() - set bridge supported image formats
> + * @bridge: the bridge to set image formats in
> + * @formats: array of MEDIA_BUS_FMT\_ supported image formats
> + * @num_formats: number of elements in the @formats array
> + *
> + * Store a list of supported image formats in a bridge.
> + * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h 
> for
> + * a full list of available formats.
> + */
> +int drm_bridge_set_bus_formats(struct drm_bridge *bridge, const u32 *formats,
> +unsigned int num_formats)
> +{
> + u32 *fmts;
> +
> + if (!formats || !num_formats)
> + return -EINVAL;

I see no compelling reason to forbid restoring the number of reported
input formats to zero? I can't think of a use right now of course, but it
seems a bit odd all the same.

Cheers,
Peter

> +
> + fmts = kmemdup(formats, sizeof(*formats) * num_formats, GFP_KERNEL);
> + if (!fmts)
> + return -ENOMEM;
> +
> + kfree(bridge->bus_formats);
> + bridge->bus_formats = fmts;
> + bridge->num_bus_formats = num_formats;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(drm_bridge_set_bus_formats);
> +
> +/**
>   * DOC: bridge callbacks
>   *
>   * The _bridge_funcs ops are populated by the bridge driver. The DRM
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index 3270fec..6b3648c 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -258,6 +258,9 @@ struct drm_bridge_timings {
>   * @encoder: encoder to which this bridge is connected
>   * @next: the next bridge in the encoder chain
>   * @of_node: device node pointer to the bridge
> + * @bus_formats: wire image formats. Array of @num_bus_formats 
> MEDIA_BUS_FMT\_
> + * elements
> + * @num_bus_formats: size of @bus_formats array
>   * @list: to keep track of all added bridges
>   * @timings: the timing specification for the bridge, if any (may
>   * be NULL)
> @@ -271,6 +274,9 @@ struct drm_bridge {
>  #ifdef CONFIG_OF
>   struct device_node *of_node;
>  #endif
> + const u32 *bus_formats;
> + unsigned int num_bus_formats;
> +
>   struct list_head list;
>   const struct drm_bridge_timings *timings;
>  
> @@ -296,6 +302,8 @@ void drm_bridge_mode_set(struct drm_bridge *bridge,
>   struct drm_display_mode *adjusted_mode);
>  void drm_bridge_pre_enable(struct drm_bridge *bridge);
>  void drm_bridge_enable(struct drm_bridge *bridge);
> +int drm_bridge_set_bus_formats(struct drm_bridge *bridge, const u32 *fmts,
> +unsigned int num_fmts);
>  
>  #ifdef CONFIG_DRM_PANEL_BRIDGE
>  struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel,
> 



Re: [PATCH 2/7] media: meye: allow building it with COMPILE_TEST on non-x86

2018-04-22 Thread Andy Shevchenko
On Fri, Apr 20, 2018 at 8:42 PM, Mauro Carvalho Chehab
 wrote:
> This driver depends on sony-laptop driver, but this is available
> only for x86. So, add a stub function, in order to allow building
> it on non-x86 too.

> --- a/include/linux/sony-laptop.h
> +++ b/include/linux/sony-laptop.h
> @@ -28,7 +28,11 @@
>  #define SONY_PIC_COMMAND_GETCAMERAROMVERSION   18  /* obsolete */
>  #define SONY_PIC_COMMAND_GETCAMERAREVISION 19  /* obsolete */
>
> +#ifdef CONFIG_SONY_LAPTOP

IS_ENABLED(), IS_BUILTIN() ?

>  int sony_pic_camera_command(int command, u8 value);
> +#else
> +static inline int sony_pic_camera_command(int command, u8 value) { return 0; 
> };
> +#endif
>
>  #endif /* __KERNEL__ */



-- 
With Best Regards,
Andy Shevchenko


[RFC PATCH] sound, media: array_find() can be static

2018-04-22 Thread kbuild test robot

Fixes: dbd775375e7d ("sound, media: allow building ISA drivers it with 
COMPILE_TEST")
Signed-off-by: Fengguang Wu 
---
 cmi8328.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/isa/cmi8328.c b/sound/isa/cmi8328.c
index d09e456..de6ef1b 100644
--- a/sound/isa/cmi8328.c
+++ b/sound/isa/cmi8328.c
@@ -192,7 +192,7 @@ static int snd_cmi8328_mixer(struct snd_wss *chip)
 }
 
 /* find index of an item in "-1"-ended array */
-int array_find(int array[], int item)
+static int array_find(int array[], int item)
 {
int i;
 
@@ -203,7 +203,7 @@ int array_find(int array[], int item)
return -1;
 }
 /* the same for long */
-int array_find_l(long array[], long item)
+static int array_find_l(long array[], long item)
 {
int i;
 


Re: [PATCH 3/4] sound, media: allow building ISA drivers it with COMPILE_TEST

2018-04-22 Thread kbuild test robot
Hi Mauro,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.17-rc1 next-20180420]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Mauro-Carvalho-Chehab/media-radio-allow-building-ISA-drivers-with-COMPILE_TEST/20180422-180508
base:   git://linuxtv.org/media_tree.git master
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> sound/isa/wss/wss_lib.c:551:14: sparse: restricted snd_pcm_format_t degrades 
>> to integer
   sound/isa/wss/wss_lib.c:552:14: sparse: restricted snd_pcm_format_t degrades 
to integer
   sound/isa/wss/wss_lib.c:553:14: sparse: restricted snd_pcm_format_t degrades 
to integer
   sound/isa/wss/wss_lib.c:554:14: sparse: restricted snd_pcm_format_t degrades 
to integer
   sound/isa/wss/wss_lib.c:555:14: sparse: restricted snd_pcm_format_t degrades 
to integer
>> sound/isa/wss/wss_lib.c:1003:58: sparse: incorrect type in argument 2 
>> (different base types) @@expected int [signed] format @@got 
>> restricted sndint [signed] format @@
   sound/isa/wss/wss_lib.c:1003:58:expected int [signed] format
   sound/isa/wss/wss_lib.c:1003:58:got restricted snd_pcm_format_t
   sound/isa/wss/wss_lib.c:1046:58: sparse: incorrect type in argument 2 
(different base types) @@expected int [signed] format @@got restricted 
sndint [signed] format @@
   sound/isa/wss/wss_lib.c:1046:58:expected int [signed] format
   sound/isa/wss/wss_lib.c:1046:58:got restricted snd_pcm_format_t
--
>> drivers/media/radio/radio-miropcm20.c:292:21: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-miropcm20.c:292:21: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-miropcm20.c:292:21: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-miropcm20.c:292:21: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-miropcm20.c:292:21: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-miropcm20.c:292:21: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-miropcm20.c:292:21: sparse: expression using 
>> sizeof(void)
--
>> sound/isa/cmi8328.c:195:5: sparse: symbol 'array_find' was not declared. 
>> Should it be static?
>> sound/isa/cmi8328.c:206:5: sparse: symbol 'array_find_l' was not declared. 
>> Should it be static?
--
>> sound/isa/sscape.c:477:23: sparse: expression using sizeof(void)
>> sound/isa/sscape.c:477:23: sparse: expression using sizeof(void)
--
>> sound/isa/msnd/msnd_pinnacle.c:85:32: sparse: incorrect type in assignment 
>> (different base types) @@expected int [signed] play_sample_size @@
>> got restricted snd_pcm_format_int [signed] play_sample_size @@
   sound/isa/msnd/msnd_pinnacle.c:85:32:expected int [signed] 
play_sample_size
   sound/isa/msnd/msnd_pinnacle.c:85:32:got restricted snd_pcm_format_t 
[usertype] 
>> sound/isa/msnd/msnd_pinnacle.c:88:35: sparse: incorrect type in assignment 
>> (different base types) @@expected int [signed] capture_sample_size @@
>> got restricted snd_pcm_format_int [signed] capture_sample_size @@
   sound/isa/msnd/msnd_pinnacle.c:88:35:expected int [signed] 
capture_sample_size
   sound/isa/msnd/msnd_pinnacle.c:88:35:got restricted snd_pcm_format_t 
[usertype] 
>> sound/isa/msnd/msnd_pinnacle.c:172:45: sparse: incorrect type in initializer 
>> (different address spaces) @@expected void *pwDSPQData @@got void 
>> [noderef] *
>> sound/isa/msnd/msnd_pinnacle.c:185:62: sparse: incorrect type in argument 1 
>> (different address spaces) @@expected void const volatile [noderef] 
>> *addr @@got sn:2>*addr @@
   sound/isa/msnd/msnd_pinnacle.c:185:62:expected void const volatile 
[noderef] *addr
   sound/isa/msnd/msnd_pinnacle.c:185:62:got void *
>> sound/isa/msnd/msnd_pinnacle.c:344:33: sparse: incorrect type in argument 1 
>> (different address spaces) @@expected void *base @@got void 
>> [noderef] *DAPQ
   sound/isa/msnd/msnd_pinnacle.c:348:33: sparse: incorrect type in argument 1 
(different address spaces) @@expected void *base @@got void [noderef] 
*DARQ
   sound/isa/msnd/msnd_pinnacle.c:352:33: sparse: incorrect type in argument 1 
(different address spaces) @@expected void *base @@got void [noderef] 
*MODQ
   sound/isa/msnd/msnd_pinnacle.c:356:33: sparse: incorrect type in argument 1 
(different address spaces) @@expected void *base @@got void [noderef] 
*MIDQ
   sound/isa/msnd/msnd_pinnacle.c:360:33: spar

[PATCH 2/2] [media] ngene: fix ci_tsfix modparam description typo

2018-04-22 Thread Daniel Scheller
From: Daniel Scheller 

s/shifs/shifts/

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ngene/ngene-dvb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ngene/ngene-dvb.c 
b/drivers/media/pci/ngene/ngene-dvb.c
index fee89b9ed9c1..5147e83397a1 100644
--- a/drivers/media/pci/ngene/ngene-dvb.c
+++ b/drivers/media/pci/ngene/ngene-dvb.c
@@ -40,7 +40,7 @@
 
 static int ci_tsfix = 1;
 module_param(ci_tsfix, int, 0444);
-MODULE_PARM_DESC(ci_tsfix, "Detect and fix TS buffer offset shifs in 
conjunction with CI expansions (default: 1/enabled)");
+MODULE_PARM_DESC(ci_tsfix, "Detect and fix TS buffer offset shifts in 
conjunction with CI expansions (default: 1/enabled)");
 
 //
 /* COMMAND API interface /
-- 
2.16.1



[PATCH 1/2] [media] ngene: cleanup superfluous I2C adapter evaluation

2018-04-22 Thread Daniel Scheller
From: Daniel Scheller 

Commit ee93340e98bc ("media: ngene: deduplicate I2C adapter evaluation")
added a helper to evaluate the I2C adapter to be used for demod/tuner
attachment based on the given ngene_channel, and that helper is used in
many attach functions to initialise the i2c_adapter variable. However,
for some reason in tuner_attach_stv6110() and demod_attach_stv0900(), the
adapter evaluation wasn't removed as in all other functions. Fix (or
finalize, even) the helper use by cleaning up the superfluous I2C adapter
evaluation leftover in these two functions.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ngene/ngene-cards.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/media/pci/ngene/ngene-cards.c 
b/drivers/media/pci/ngene/ngene-cards.c
index 65fc8f23ad86..caa5976055c4 100644
--- a/drivers/media/pci/ngene/ngene-cards.c
+++ b/drivers/media/pci/ngene/ngene-cards.c
@@ -137,11 +137,6 @@ static int tuner_attach_stv6110(struct ngene_channel *chan)
chan->dev->card_info->tuner_config[chan->number];
const struct stv6110x_devctl *ctl;
 
-   if (chan->number < 2)
-   i2c = >dev->channel[0].i2c_adapter;
-   else
-   i2c = >dev->channel[1].i2c_adapter;
-
ctl = dvb_attach(stv6110x_attach, chan->fe, tunerconf, i2c);
if (ctl == NULL) {
dev_err(pdev, "No STV6110X found!\n");
@@ -304,14 +299,6 @@ static int demod_attach_stv0900(struct ngene_channel *chan)
struct stv090x_config *feconf = (struct stv090x_config *)
chan->dev->card_info->fe_config[chan->number];
 
-   /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
-   /* Note: Both adapters share the same i2c bus, but the demod */
-   /*   driver requires that each demod has its own i2c adapter */
-   if (chan->number < 2)
-   i2c = >dev->channel[0].i2c_adapter;
-   else
-   i2c = >dev->channel[1].i2c_adapter;
-
chan->fe = dvb_attach(stv090x_attach, feconf, i2c,
(chan->number & 1) == 0 ? STV090x_DEMODULATOR_0
: STV090x_DEMODULATOR_1);
-- 
2.16.1



[PATCH v3 05/11] media: ov772x: use generic names for reset and powerdown gpios

2018-04-22 Thread Akinobu Mita
The ov772x driver uses "rstb-gpios" and "pwdn-gpios" for reset and
powerdown pins.  However, using generic names for these gpios is
preferred.  ("reset-gpios" and "powerdown-gpios" respectively)

There is only one mainline user for these gpios, so rename to generic
names.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Reviewed-by: Jacopo Mondi 
Signed-off-by: Akinobu Mita 
---
* v3
- Fix typo in the commit log
- Add a Reviewed-by: line

 arch/sh/boards/mach-migor/setup.c | 5 +++--
 drivers/media/i2c/ov772x.c| 8 
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/sh/boards/mach-migor/setup.c 
b/arch/sh/boards/mach-migor/setup.c
index 271dfc2..73b9ee4 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -351,8 +351,9 @@ static struct platform_device migor_ceu_device = {
 static struct gpiod_lookup_table ov7725_gpios = {
.dev_id = "0-0021",
.table  = {
-   GPIO_LOOKUP("sh7722_pfc", GPIO_PTT0, "pwdn", GPIO_ACTIVE_HIGH),
-   GPIO_LOOKUP("sh7722_pfc", GPIO_PTT3, "rstb", GPIO_ACTIVE_LOW),
+   GPIO_LOOKUP("sh7722_pfc", GPIO_PTT0, "powerdown",
+   GPIO_ACTIVE_HIGH),
+   GPIO_LOOKUP("sh7722_pfc", GPIO_PTT3, "reset", GPIO_ACTIVE_LOW),
},
 };
 
diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index 18a5ed6..8cac206 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -837,10 +837,10 @@ static int ov772x_power_on(struct ov772x_priv *priv)
 * available to handle this cleanly, request the GPIO temporarily
 * to avoid conflicts.
 */
-   priv->rstb_gpio = gpiod_get_optional(>dev, "rstb",
+   priv->rstb_gpio = gpiod_get_optional(>dev, "reset",
 GPIOD_OUT_LOW);
if (IS_ERR(priv->rstb_gpio)) {
-   dev_info(>dev, "Unable to get GPIO \"rstb\"");
+   dev_info(>dev, "Unable to get GPIO \"reset\"");
return PTR_ERR(priv->rstb_gpio);
}
 
@@ -1307,10 +1307,10 @@ static int ov772x_probe(struct i2c_client *client,
goto error_ctrl_free;
}
 
-   priv->pwdn_gpio = gpiod_get_optional(>dev, "pwdn",
+   priv->pwdn_gpio = gpiod_get_optional(>dev, "powerdown",
 GPIOD_OUT_LOW);
if (IS_ERR(priv->pwdn_gpio)) {
-   dev_info(>dev, "Unable to get GPIO \"pwdn\"");
+   dev_info(>dev, "Unable to get GPIO \"powerdown\"");
ret = PTR_ERR(priv->pwdn_gpio);
goto error_clk_put;
}
-- 
2.7.4



[PATCH v3 04/11] media: ov772x: add media controller support

2018-04-22 Thread Akinobu Mita
Create a source pad and set the media controller type to the sensor.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Reviewed-by: Jacopo Mondi 
Signed-off-by: Akinobu Mita 
---
* v3
- Add a Reviewed-by: line

 drivers/media/i2c/ov772x.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index f25150d..18a5ed6 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -424,6 +424,9 @@ struct ov772x_priv {
/* band_filter = COM8[5] ? 256 - BDBASE : 0 */
unsigned shortband_filter;
unsigned int  fps;
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_pad pad;
+#endif
 };
 
 /*
@@ -1316,16 +1319,26 @@ static int ov772x_probe(struct i2c_client *client,
if (ret < 0)
goto error_gpio_put;
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+   priv->pad.flags = MEDIA_PAD_FL_SOURCE;
+   priv->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
+   ret = media_entity_pads_init(>subdev.entity, 1, >pad);
+   if (ret < 0)
+   goto error_gpio_put;
+#endif
+
priv->cfmt = _cfmts[0];
priv->win = _win_sizes[0];
priv->fps = 15;
 
ret = v4l2_async_register_subdev(>subdev);
if (ret)
-   goto error_gpio_put;
+   goto error_entity_cleanup;
 
return 0;
 
+error_entity_cleanup:
+   media_entity_cleanup(>subdev.entity);
 error_gpio_put:
if (priv->pwdn_gpio)
gpiod_put(priv->pwdn_gpio);
@@ -1341,6 +1354,7 @@ static int ov772x_remove(struct i2c_client *client)
 {
struct ov772x_priv *priv = to_ov772x(i2c_get_clientdata(client));
 
+   media_entity_cleanup(>subdev.entity);
clk_put(priv->clk);
if (priv->pwdn_gpio)
gpiod_put(priv->pwdn_gpio);
-- 
2.7.4



[PATCH v3 09/11] media: ov772x: avoid accessing registers under power saving mode

2018-04-22 Thread Akinobu Mita
The set_fmt() in subdev pad ops, the s_ctrl() for subdev control handler,
and the s_frame_interval() in subdev video ops could be called when the
device is under power saving mode.  These callbacks for ov772x driver
cause updating H/W registers that will fail under power saving mode.

This avoids it by not apply any changes to H/W if the device is not powered
up.  Instead the changes will be restored right after power-up.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
* v3
- Add newlines before labels
- Remove __v4l2_ctrl_handler_setup in s_power() as it causes duplicated
  register settings

 drivers/media/i2c/ov772x.c | 79 +-
 1 file changed, 64 insertions(+), 15 deletions(-)

diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index 452406c..96dd37a 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -741,19 +741,30 @@ static int ov772x_s_frame_interval(struct v4l2_subdev *sd,
struct ov772x_priv *priv = to_ov772x(sd);
struct v4l2_fract *tpf = >interval;
unsigned int fps;
-   int ret;
+   int ret = 0;
 
fps = ov772x_select_fps(priv, tpf);
 
-   ret = ov772x_set_frame_rate(priv, fps, priv->cfmt, priv->win);
-   if (ret)
-   return ret;
+   mutex_lock(>lock);
+   /*
+* If the device is not powered up by the host driver do
+* not apply any changes to H/W at this time. Instead
+* the frame rate will be restored right after power-up.
+*/
+   if (priv->power_count > 0) {
+   ret = ov772x_set_frame_rate(priv, fps, priv->cfmt, priv->win);
+   if (ret)
+   goto error;
+   }
 
tpf->numerator = 1;
tpf->denominator = fps;
priv->fps = fps;
 
-   return 0;
+error:
+   mutex_unlock(>lock);
+
+   return ret;
 }
 
 static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl)
@@ -765,6 +776,16 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl)
int ret = 0;
u8 val;
 
+   /* v4l2_ctrl_lock() locks our own mutex */
+
+   /*
+* If the device is not powered up by the host driver do
+* not apply any controls to H/W at this time. Instead
+* the controls will be restored right after power-up.
+*/
+   if (priv->power_count == 0)
+   return 0;
+
switch (ctrl->id) {
case V4L2_CID_VFLIP:
val = ctrl->val ? VFLIP_IMG : 0x00;
@@ -888,6 +909,10 @@ static int ov772x_power_off(struct ov772x_priv *priv)
return 0;
 }
 
+static int ov772x_set_params(struct ov772x_priv *priv,
+const struct ov772x_color_format *cfmt,
+const struct ov772x_win_size *win);
+
 static int ov772x_s_power(struct v4l2_subdev *sd, int on)
 {
struct ov772x_priv *priv = to_ov772x(sd);
@@ -898,8 +923,20 @@ static int ov772x_s_power(struct v4l2_subdev *sd, int on)
/* If the power count is modified from 0 to != 0 or from != 0 to 0,
 * update the power state.
 */
-   if (priv->power_count == !on)
-   ret = on ? ov772x_power_on(priv) : ov772x_power_off(priv);
+   if (priv->power_count == !on) {
+   if (on) {
+   ret = ov772x_power_on(priv);
+   /*
+* Restore the format, the frame rate, and
+* the controls
+*/
+   if (!ret)
+   ret = ov772x_set_params(priv, priv->cfmt,
+   priv->win);
+   } else {
+   ret = ov772x_power_off(priv);
+   }
+   }
 
if (!ret) {
/* Update the power count. */
@@ -1164,7 +1201,7 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *mf = >format;
const struct ov772x_color_format *cfmt;
const struct ov772x_win_size *win;
-   int ret;
+   int ret = 0;
 
if (format->pad)
return -EINVAL;
@@ -1185,14 +1222,24 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
return 0;
}
 
-   ret = ov772x_set_params(priv, cfmt, win);
-   if (ret < 0)
-   return ret;
-
+   mutex_lock(>lock);
+   /*
+* If the device is not powered up by the host driver do
+* not apply any changes to H/W at this time. Instead
+* the format will be restored right after power-up.
+*/
+   if (priv->power_count > 0) {
+   ret = ov772x_set_params(priv, cfmt, win);
+   if (ret < 0)
+  

[PATCH v3 10/11] media: ov772x: make set_fmt() return -EBUSY while streaming

2018-04-22 Thread Akinobu Mita
The ov772x driver is going to offer a V4L2 sub-device interface, so
changing the output data format on this sub-device can be made anytime.
However, the request is preferred to fail while the video stream on the
device is active.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
* v3
- New patch

 drivers/media/i2c/ov772x.c | 35 ++-
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index 96dd37a..c9fdc67 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -424,9 +424,10 @@ struct ov772x_priv {
/* band_filter = COM8[5] ? 256 - BDBASE : 0 */
unsigned shortband_filter;
unsigned int  fps;
-   /* lock to protect power_count */
+   /* lock to protect power_count and streaming */
struct mutex  lock;
int   power_count;
+   int   streaming;
 #ifdef CONFIG_MEDIA_CONTROLLER
struct media_pad pad;
 #endif
@@ -603,18 +604,28 @@ static int ov772x_s_stream(struct v4l2_subdev *sd, int 
enable)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct ov772x_priv *priv = to_ov772x(sd);
+   int ret = 0;
 
-   if (!enable) {
-   ov772x_mask_set(client, COM2, SOFT_SLEEP_MODE, SOFT_SLEEP_MODE);
-   return 0;
-   }
+   mutex_lock(>lock);
 
-   ov772x_mask_set(client, COM2, SOFT_SLEEP_MODE, 0);
+   if (priv->streaming == enable)
+   goto done;
 
-   dev_dbg(>dev, "format %d, win %s\n",
-   priv->cfmt->code, priv->win->name);
+   ret = ov772x_mask_set(client, COM2, SOFT_SLEEP_MODE,
+ enable ? 0 : SOFT_SLEEP_MODE);
+   if (ret)
+   goto done;
 
-   return 0;
+   if (enable) {
+   dev_dbg(>dev, "format %d, win %s\n",
+   priv->cfmt->code, priv->win->name);
+   }
+   priv->streaming = enable;
+
+done:
+   mutex_unlock(>lock);
+
+   return ret;
 }
 
 static unsigned int ov772x_select_fps(struct ov772x_priv *priv,
@@ -1223,6 +1234,12 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
}
 
mutex_lock(>lock);
+
+   if (priv->streaming) {
+   ret = -EBUSY;
+   goto error;
+   }
+
/*
 * If the device is not powered up by the host driver do
 * not apply any changes to H/W at this time. Instead
-- 
2.7.4



[PATCH v3 08/11] media: ov772x: reconstruct s_frame_interval()

2018-04-22 Thread Akinobu Mita
This splits the s_frame_interval() in subdev video ops into selecting the
frame interval and setting up the registers.

This is a preparatory change to avoid accessing registers under power
saving mode.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
* v3
- No changes

 drivers/media/i2c/ov772x.c | 56 +-
 1 file changed, 35 insertions(+), 21 deletions(-)

diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index 8c0b850..452406c 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -617,25 +617,16 @@ static int ov772x_s_stream(struct v4l2_subdev *sd, int 
enable)
return 0;
 }
 
-static int ov772x_set_frame_rate(struct ov772x_priv *priv,
-struct v4l2_fract *tpf,
-const struct ov772x_color_format *cfmt,
-const struct ov772x_win_size *win)
+static unsigned int ov772x_select_fps(struct ov772x_priv *priv,
+struct v4l2_fract *tpf)
 {
-   struct i2c_client *client = v4l2_get_subdevdata(>subdev);
-   unsigned long fin = clk_get_rate(priv->clk);
unsigned int fps = tpf->numerator ?
   tpf->denominator / tpf->numerator :
   tpf->denominator;
unsigned int best_diff;
-   unsigned int fsize;
-   unsigned int pclk;
unsigned int diff;
unsigned int idx;
unsigned int i;
-   u8 clkrc = 0;
-   u8 com4 = 0;
-   int ret;
 
/* Approximate to the closest supported frame interval. */
best_diff = ~0L;
@@ -646,7 +637,25 @@ static int ov772x_set_frame_rate(struct ov772x_priv *priv,
best_diff = diff;
}
}
-   fps = ov772x_frame_intervals[idx];
+
+   return ov772x_frame_intervals[idx];
+}
+
+static int ov772x_set_frame_rate(struct ov772x_priv *priv,
+unsigned int fps,
+const struct ov772x_color_format *cfmt,
+const struct ov772x_win_size *win)
+{
+   struct i2c_client *client = v4l2_get_subdevdata(>subdev);
+   unsigned long fin = clk_get_rate(priv->clk);
+   unsigned int fsize;
+   unsigned int pclk;
+   unsigned int best_diff;
+   unsigned int diff;
+   unsigned int i;
+   u8 clkrc = 0;
+   u8 com4 = 0;
+   int ret;
 
/* Use image size (with blankings) to calculate desired pixel clock. */
switch (cfmt->com7 & OFMT_MASK) {
@@ -711,10 +720,6 @@ static int ov772x_set_frame_rate(struct ov772x_priv *priv,
if (ret < 0)
return ret;
 
-   tpf->numerator = 1;
-   tpf->denominator = fps;
-   priv->fps = tpf->denominator;
-
return 0;
 }
 
@@ -735,8 +740,20 @@ static int ov772x_s_frame_interval(struct v4l2_subdev *sd,
 {
struct ov772x_priv *priv = to_ov772x(sd);
struct v4l2_fract *tpf = >interval;
+   unsigned int fps;
+   int ret;
+
+   fps = ov772x_select_fps(priv, tpf);
+
+   ret = ov772x_set_frame_rate(priv, fps, priv->cfmt, priv->win);
+   if (ret)
+   return ret;
 
-   return ov772x_set_frame_rate(priv, tpf, priv->cfmt, priv->win);
+   tpf->numerator = 1;
+   tpf->denominator = fps;
+   priv->fps = fps;
+
+   return 0;
 }
 
 static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl)
@@ -993,7 +1010,6 @@ static int ov772x_set_params(struct ov772x_priv *priv,
 const struct ov772x_win_size *win)
 {
struct i2c_client *client = v4l2_get_subdevdata(>subdev);
-   struct v4l2_fract tpf;
int ret;
u8  val;
 
@@ -1075,9 +1091,7 @@ static int ov772x_set_params(struct ov772x_priv *priv,
goto ov772x_set_fmt_error;
 
/* COM4, CLKRC: Set pixel clock and framerate. */
-   tpf.numerator = 1;
-   tpf.denominator = priv->fps;
-   ret = ov772x_set_frame_rate(priv, , cfmt, win);
+   ret = ov772x_set_frame_rate(priv, priv->fps, cfmt, win);
if (ret < 0)
goto ov772x_set_fmt_error;
 
-- 
2.7.4



[PATCH v3 07/11] media: ov772x: handle nested s_power() calls

2018-04-22 Thread Akinobu Mita
Depending on the v4l2 driver, calling s_power() could be nested.  So the
actual transitions between power saving mode and normal operation mode
should only happen at the first power on and the last power off.

This adds an s_power() nesting counter and updates the power state if the
counter is modified from 0 to != 0 or from != 0 to 0.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
* v3
- Rename mutex name from power_lock to lock
- Add warning for duplicated s_power call

 drivers/media/i2c/ov772x.c | 34 ++
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index 95c1c95d..8c0b850 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -424,6 +424,9 @@ struct ov772x_priv {
/* band_filter = COM8[5] ? 256 - BDBASE : 0 */
unsigned shortband_filter;
unsigned int  fps;
+   /* lock to protect power_count */
+   struct mutex  lock;
+   int   power_count;
 #ifdef CONFIG_MEDIA_CONTROLLER
struct media_pad pad;
 #endif
@@ -871,9 +874,26 @@ static int ov772x_power_off(struct ov772x_priv *priv)
 static int ov772x_s_power(struct v4l2_subdev *sd, int on)
 {
struct ov772x_priv *priv = to_ov772x(sd);
+   int ret = 0;
+
+   mutex_lock(>lock);
+
+   /* If the power count is modified from 0 to != 0 or from != 0 to 0,
+* update the power state.
+*/
+   if (priv->power_count == !on)
+   ret = on ? ov772x_power_on(priv) : ov772x_power_off(priv);
+
+   if (!ret) {
+   /* Update the power count. */
+   priv->power_count += on ? 1 : -1;
+   WARN(priv->power_count < 0, "Unbalanced power count\n");
+   WARN(priv->power_count > 1, "Duplicated s_power call\n");
+   }
+
+   mutex_unlock(>lock);
 
-   return on ? ov772x_power_on(priv) :
-   ov772x_power_off(priv);
+   return ret;
 }
 
 static const struct ov772x_win_size *ov772x_select_win(u32 width, u32 height)
@@ -1303,6 +1323,7 @@ static int ov772x_probe(struct i2c_client *client,
return -ENOMEM;
 
priv->info = client->dev.platform_data;
+   mutex_init(>lock);
 
v4l2_i2c_subdev_init(>subdev, client, _subdev_ops);
v4l2_ctrl_handler_init(>hdl, 3);
@@ -1313,8 +1334,10 @@ static int ov772x_probe(struct i2c_client *client,
v4l2_ctrl_new_std(>hdl, _ctrl_ops,
  V4L2_CID_BAND_STOP_FILTER, 0, 256, 1, 0);
priv->subdev.ctrl_handler = >hdl;
-   if (priv->hdl.error)
-   return priv->hdl.error;
+   if (priv->hdl.error) {
+   ret = priv->hdl.error;
+   goto error_mutex_destroy;
+   }
 
priv->clk = clk_get(>dev, "xclk");
if (IS_ERR(priv->clk)) {
@@ -1362,6 +1385,8 @@ static int ov772x_probe(struct i2c_client *client,
clk_put(priv->clk);
 error_ctrl_free:
v4l2_ctrl_handler_free(>hdl);
+error_mutex_destroy:
+   mutex_destroy(>lock);
 
return ret;
 }
@@ -1376,6 +1401,7 @@ static int ov772x_remove(struct i2c_client *client)
gpiod_put(priv->pwdn_gpio);
v4l2_async_unregister_subdev(>subdev);
v4l2_ctrl_handler_free(>hdl);
+   mutex_destroy(>lock);
 
return 0;
 }
-- 
2.7.4



[PATCH v3 06/11] media: ov772x: support device tree probing

2018-04-22 Thread Akinobu Mita
The ov772x driver currently only supports legacy platform data probe.
This change enables device tree probing.

Note that the platform data probe can select auto or manual edge control
mode, but the device tree probling can only select auto edge control mode
for now.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Reviewed-by: Jacopo Mondi 
Signed-off-by: Akinobu Mita 
---
* v3
- Add a Reviewed-by: line
- Return without resetting if ov772x_edgectrl() failed
- Update the error message for missing platform data

 drivers/media/i2c/ov772x.c | 64 --
 1 file changed, 45 insertions(+), 19 deletions(-)

diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index 8cac206..95c1c95d 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -749,13 +749,13 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_VFLIP:
val = ctrl->val ? VFLIP_IMG : 0x00;
priv->flag_vflip = ctrl->val;
-   if (priv->info->flags & OV772X_FLAG_VFLIP)
+   if (priv->info && (priv->info->flags & OV772X_FLAG_VFLIP))
val ^= VFLIP_IMG;
return ov772x_mask_set(client, COM3, VFLIP_IMG, val);
case V4L2_CID_HFLIP:
val = ctrl->val ? HFLIP_IMG : 0x00;
priv->flag_hflip = ctrl->val;
-   if (priv->info->flags & OV772X_FLAG_HFLIP)
+   if (priv->info && (priv->info->flags & OV772X_FLAG_HFLIP))
val ^= HFLIP_IMG;
return ov772x_mask_set(client, COM3, HFLIP_IMG, val);
case V4L2_CID_BAND_STOP_FILTER:
@@ -914,19 +914,14 @@ static void ov772x_select_params(const struct 
v4l2_mbus_framefmt *mf,
*win = ov772x_select_win(mf->width, mf->height);
 }
 
-static int ov772x_set_params(struct ov772x_priv *priv,
-const struct ov772x_color_format *cfmt,
-const struct ov772x_win_size *win)
+static int ov772x_edgectrl(struct ov772x_priv *priv)
 {
struct i2c_client *client = v4l2_get_subdevdata(>subdev);
-   struct v4l2_fract tpf;
int ret;
-   u8  val;
 
-   /* Reset hardware. */
-   ov772x_reset(client);
+   if (!priv->info)
+   return 0;
 
-   /* Edge Ctrl. */
if (priv->info->edgectrl.strength & OV772X_MANUAL_EDGE_CTRL) {
/*
 * Manual Edge Control Mode.
@@ -937,19 +932,19 @@ static int ov772x_set_params(struct ov772x_priv *priv,
 
ret = ov772x_mask_set(client, DSPAUTO, EDGE_ACTRL, 0x00);
if (ret < 0)
-   goto ov772x_set_fmt_error;
+   return ret;
 
ret = ov772x_mask_set(client,
  EDGE_TRSHLD, OV772X_EDGE_THRESHOLD_MASK,
  priv->info->edgectrl.threshold);
if (ret < 0)
-   goto ov772x_set_fmt_error;
+   return ret;
 
ret = ov772x_mask_set(client,
  EDGE_STRNGT, OV772X_EDGE_STRENGTH_MASK,
  priv->info->edgectrl.strength);
if (ret < 0)
-   goto ov772x_set_fmt_error;
+   return ret;
 
} else if (priv->info->edgectrl.upper > priv->info->edgectrl.lower) {
/*
@@ -961,15 +956,35 @@ static int ov772x_set_params(struct ov772x_priv *priv,
  EDGE_UPPER, OV772X_EDGE_UPPER_MASK,
  priv->info->edgectrl.upper);
if (ret < 0)
-   goto ov772x_set_fmt_error;
+   return ret;
 
ret = ov772x_mask_set(client,
  EDGE_LOWER, OV772X_EDGE_LOWER_MASK,
  priv->info->edgectrl.lower);
if (ret < 0)
-   goto ov772x_set_fmt_error;
+   return ret;
}
 
+   return 0;
+}
+
+static int ov772x_set_params(struct ov772x_priv *priv,
+const struct ov772x_color_format *cfmt,
+const struct ov772x_win_size *win)
+{
+   struct i2c_client *client = v4l2_get_subdevdata(>subdev);
+   struct v4l2_fract tpf;
+   int ret;
+   u8  val;
+
+   /* Reset hardware. */
+   ov772x_reset(client);
+
+   /* Edge Ctrl. */
+   ret =  ov772x_edgectrl(priv);
+   if (ret < 0)
+   return ret;
+
/* Format and window size. */
ret = ov772x_write(client, HSTART, win->rect.left >> 2);

[PATCH v3 11/11] media: ov772x: create subdevice device node

2018-04-22 Thread Akinobu Mita
Set the V4L2_SUBDEV_FL_HAS_DEVNODE flag for the subdevice so that the
subdevice device node is created.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
* v3
- No changes

 drivers/media/i2c/ov772x.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index c9fdc67..a41c9d3 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -1404,6 +1404,7 @@ static int ov772x_probe(struct i2c_client *client,
mutex_init(>lock);
 
v4l2_i2c_subdev_init(>subdev, client, _subdev_ops);
+   priv->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
v4l2_ctrl_handler_init(>hdl, 3);
/* Use our mutex for the controls */
priv->hdl.lock = >lock;
-- 
2.7.4



[PATCH v3 01/11] media: dt-bindings: ov772x: add device tree binding

2018-04-22 Thread Akinobu Mita
This adds a device tree binding documentation for OV7720/OV7725 sensor.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Cc: Rob Herring 
Reviewed-by: Rob Herring 
Reviewed-by: Jacopo Mondi 
Signed-off-by: Akinobu Mita 
---
* v3
- Add Reviewed-by: lines

 .../devicetree/bindings/media/i2c/ov772x.txt   | 42 ++
 MAINTAINERS|  1 +
 2 files changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov772x.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov772x.txt 
b/Documentation/devicetree/bindings/media/i2c/ov772x.txt
new file mode 100644
index 000..b045503
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov772x.txt
@@ -0,0 +1,42 @@
+* Omnivision OV7720/OV7725 CMOS sensor
+
+The Omnivision OV7720/OV7725 sensor supports multiple resolutions output,
+such as VGA, QVGA, and any size scaling down from CIF to 40x30. It also can
+support the YUV422, RGB565/555/444, GRB422 or raw RGB output formats.
+
+Required Properties:
+- compatible: shall be one of
+   "ovti,ov7720"
+   "ovti,ov7725"
+- clocks: reference to the xclk input clock.
+- clock-names: shall be "xclk".
+
+Optional Properties:
+- reset-gpios: reference to the GPIO connected to the RSTB pin which is
+  active low, if any.
+- powerdown-gpios: reference to the GPIO connected to the PWDN pin which is
+  active high, if any.
+
+The device node shall contain one 'port' child node with one child 'endpoint'
+subnode for its digital output video port, in accordance with the video
+interface bindings defined in Documentation/devicetree/bindings/media/
+video-interfaces.txt.
+
+Example:
+
+ {
+   ov772x: camera@21 {
+   compatible = "ovti,ov7725";
+   reg = <0x21>;
+   reset-gpios = <_gpio_0 0 GPIO_ACTIVE_LOW>;
+   powerdown-gpios = <_gpio_0 1 GPIO_ACTIVE_LOW>;
+   clocks = <>;
+   clock-names = "xclk";
+
+   port {
+   ov772x_0: endpoint {
+   remote-endpoint = <_in0>;
+   };
+   };
+   };
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 5ae51d0..1cc5fb1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10353,6 +10353,7 @@ T:  git git://linuxtv.org/media_tree.git
 S: Odd fixes
 F: drivers/media/i2c/ov772x.c
 F: include/media/i2c/ov772x.h
+F: Documentation/devicetree/bindings/media/i2c/ov772x.txt
 
 OMNIVISION OV7740 SENSOR DRIVER
 M: Wenyou Yang 
-- 
2.7.4



[PATCH v3 02/11] media: ov772x: allow i2c controllers without I2C_FUNC_PROTOCOL_MANGLING

2018-04-22 Thread Akinobu Mita
The ov772x driver only works when the i2c controller have
I2C_FUNC_PROTOCOL_MANGLING.  However, many i2c controller drivers don't
support it.

The reason that the ov772x requires I2C_FUNC_PROTOCOL_MANGLING is that
it doesn't support repeated starts.

This changes the reading ov772x register method so that it doesn't
require I2C_FUNC_PROTOCOL_MANGLING by calling two separated i2c messages.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Signed-off-by: Akinobu Mita 
---
* v3
- Remove I2C_CLIENT_SCCB flag set as it isn't needed anymore

 drivers/media/i2c/ov772x.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index b62860c..2ae730f 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -542,9 +542,19 @@ static struct ov772x_priv *to_ov772x(struct v4l2_subdev 
*sd)
return container_of(sd, struct ov772x_priv, subdev);
 }
 
-static inline int ov772x_read(struct i2c_client *client, u8 addr)
+static int ov772x_read(struct i2c_client *client, u8 addr)
 {
-   return i2c_smbus_read_byte_data(client, addr);
+   int ret;
+   u8 val;
+
+   ret = i2c_master_send(client, , 1);
+   if (ret < 0)
+   return ret;
+   ret = i2c_master_recv(client, , 1);
+   if (ret < 0)
+   return ret;
+
+   return val;
 }
 
 static inline int ov772x_write(struct i2c_client *client, u8 addr, u8 value)
@@ -1255,13 +1265,11 @@ static int ov772x_probe(struct i2c_client *client,
return -EINVAL;
}
 
-   if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
- I2C_FUNC_PROTOCOL_MANGLING)) {
+   if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
dev_err(>dev,
-   "I2C-Adapter doesn't support SMBUS_BYTE_DATA or 
PROTOCOL_MANGLING\n");
+   "I2C-Adapter doesn't support SMBUS_BYTE_DATA\n");
return -EIO;
}
-   client->flags |= I2C_CLIENT_SCCB;
 
priv = devm_kzalloc(>dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
-- 
2.7.4



[PATCH v3 03/11] media: ov772x: add checks for register read errors

2018-04-22 Thread Akinobu Mita
This change adds checks for register read errors and returns correct
error code.

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Reviewed-by: Jacopo Mondi 
Signed-off-by: Akinobu Mita 
---
* v3
- Add a Reviewed-by: line

 drivers/media/i2c/ov772x.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
index 2ae730f..f25150d 100644
--- a/drivers/media/i2c/ov772x.c
+++ b/drivers/media/i2c/ov772x.c
@@ -1146,7 +1146,7 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
 static int ov772x_video_probe(struct ov772x_priv *priv)
 {
struct i2c_client  *client = v4l2_get_subdevdata(>subdev);
-   u8  pid, ver;
+   int pid, ver, midh, midl;
const char *devname;
int ret;
 
@@ -1156,7 +1156,11 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
 
/* Check and show product ID and manufacturer ID. */
pid = ov772x_read(client, PID);
+   if (pid < 0)
+   return pid;
ver = ov772x_read(client, VER);
+   if (ver < 0)
+   return ver;
 
switch (VERSION(pid, ver)) {
case OV7720:
@@ -1172,13 +1176,17 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
goto done;
}
 
+   midh = ov772x_read(client, MIDH);
+   if (midh < 0)
+   return midh;
+   midl = ov772x_read(client, MIDL);
+   if (midl < 0)
+   return midl;
+
dev_info(>dev,
 "%s Product ID %0x:%0x Manufacturer ID %x:%x\n",
-devname,
-pid,
-ver,
-ov772x_read(client, MIDH),
-ov772x_read(client, MIDL));
+devname, pid, ver, midh, midl);
+
ret = v4l2_ctrl_handler_setup(>hdl);
 
 done:
-- 
2.7.4



[PATCH v3 00/11] media: ov772x: support media controller, device tree probing, etc.

2018-04-22 Thread Akinobu Mita
This patchset includes support media controller, sub-device interface,
device tree probing and other miscellanuous changes for ov772x driver.

* v3 (thanks to Sakari Ailus and Jacopo Mondi)
- Reorder the patches
- Add Reviewed-by: lines
- Remove I2C_CLIENT_SCCB flag set as it isn't needed anymore
- Fix typo in the commit log
- Return without resetting if ov772x_edgectrl() failed
- Update the error message for missing platform data
- Rename mutex name from power_lock to lock
- Add warning for duplicated s_power call
- Add newlines before labels
- Remove __v4l2_ctrl_handler_setup in s_power() as it causes duplicated
  register settings
- Make set_fmt() return -EBUSY while streaming (New)

* v2 (thanks to Jacopo Mondi)
- Replace the implementation of ov772x_read() instead of adding an
  alternative method
- Assign the ov772x_read() return value to pid and ver directly
- Do the same for MIDH and MIDL
- Move video_probe() before the entity initialization and remove the #ifdef
  around the media_entity_cleanup()
- Use generic names for reset and powerdown gpios (New)
- Add "dt-bindings:" in the subject
- Add a brief description of the sensor
- Update the GPIO names
- Indicate the GPIO active level
- Add missing NULL checks for priv->info
- Leave the check for the missing platform data if legacy platform data
  probe is used.
- Handle nested s_power() calls (New)
- Reconstruct s_frame_interval() (New)
- Avoid accessing registers

Akinobu Mita (11):
  media: dt-bindings: ov772x: add device tree binding
  media: ov772x: allow i2c controllers without
I2C_FUNC_PROTOCOL_MANGLING
  media: ov772x: add checks for register read errors
  media: ov772x: add media controller support
  media: ov772x: use generic names for reset and powerdown gpios
  media: ov772x: support device tree probing
  media: ov772x: handle nested s_power() calls
  media: ov772x: reconstruct s_frame_interval()
  media: ov772x: avoid accessing registers under power saving mode
  media: ov772x: make set_fmt() return -EBUSY while streaming
  media: ov772x: create subdevice device node

 .../devicetree/bindings/media/i2c/ov772x.txt   |  42 +++
 MAINTAINERS|   1 +
 arch/sh/boards/mach-migor/setup.c  |   5 +-
 drivers/media/i2c/ov772x.c | 313 -
 4 files changed, 284 insertions(+), 77 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov772x.txt

Cc: Jacopo Mondi 
Cc: Laurent Pinchart 
Cc: Hans Verkuil 
Cc: Sakari Ailus 
Cc: Mauro Carvalho Chehab 
Cc: Rob Herring 
-- 
2.7.4



Re: [PATCH 1/4] media: radio: allow building ISA drivers with COMPILE_TEST

2018-04-22 Thread kbuild test robot
Hi Mauro,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.17-rc1 next-20180420]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Mauro-Carvalho-Chehab/media-radio-allow-building-ISA-drivers-with-COMPILE_TEST/20180422-180508
base:   git://linuxtv.org/media_tree.git master
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/media/radio/radio-isa.c:108:16: sparse: expression using sizeof(void)
>> drivers/media/radio/radio-isa.c:108:16: sparse: expression using sizeof(void)
>> drivers/media/radio/radio-isa.c:108:16: sparse: expression using sizeof(void)
>> drivers/media/radio/radio-isa.c:108:16: sparse: expression using sizeof(void)
>> drivers/media/radio/radio-isa.c:108:16: sparse: expression using sizeof(void)
>> drivers/media/radio/radio-isa.c:108:16: sparse: expression using sizeof(void)
>> drivers/media/radio/radio-isa.c:108:16: sparse: expression using sizeof(void)
--
>> drivers/media/radio/radio-sf16fmi.c:123:24: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-sf16fmi.c:123:24: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-sf16fmi.c:123:24: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-sf16fmi.c:123:24: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-sf16fmi.c:123:24: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-sf16fmi.c:123:24: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-sf16fmi.c:123:24: sparse: expression using 
>> sizeof(void)
--
>> drivers/media/radio/radio-sf16fmr2.c:169:25: sparse: expression using 
>> sizeof(void)
   drivers/media/radio/radio-sf16fmr2.c:171:24: sparse: expression using 
sizeof(void)
--
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)
>> drivers/media/radio/radio-cadet.c:219:16: sparse: expression using 
>> sizeof(void)

vim +108 drivers/media/radio/radio-isa.c

137c579c Hans Verkuil 2012-02-03   98  
137c579c Hans Verkuil 2012-02-03   99  static int radio_isa_s_frequency(struct 
file *file, void *priv,
b530a447 Hans Verkuil 2013-03-19  100   const struct 
v4l2_frequency *f)
137c579c Hans Verkuil 2012-02-03  101  {
137c579c Hans Verkuil 2012-02-03  102   struct radio_isa_card *isa = 
video_drvdata(file);
b530a447 Hans Verkuil 2013-03-19  103   u32 freq = f->frequency;
137c579c Hans Verkuil 2012-02-03  104   int res;
137c579c Hans Verkuil 2012-02-03  105  
137c579c Hans Verkuil 2012-02-03  106   if (f->tuner != 0 || f->type != 
V4L2_TUNER_RADIO)
137c579c Hans Verkuil 2012-02-03  107   return -EINVAL;
b530a447 Hans Verkuil 2013-03-19 @108   freq = clamp(freq, FREQ_LOW, FREQ_HIGH);
b530a447 Hans Verkuil 2013-03-19  109   res = isa->drv->ops->s_frequency(isa, 
freq);
137c579c Hans Verkuil 2012-02-03  110   if (res == 0)
b530a447 Hans Verkuil 2013-03-19  111   isa->freq = freq;
137c579c Hans Verkuil 2012-02-03  112   return res;
137c579c Hans Verkuil 2012-02-03  113  }
137c579c Hans Verkuil 2012-02-03  114  

:: The code at line 108 was first introduced by commit
:: b530a447bb588fdf43fdf4eb909e4ee1921d47ac [media] v4l2: add const to 
argument of write-only s_frequency ioctl

:: TO: Hans Verkuil <hans.verk...@cisco.com>
:: CC: Mauro Carvalho Chehab <mche...@redhat.com>

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


[GIT PULL FOR v4.18] R-Car VSP1 changes

2018-04-22 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit 1d338b86e17d87215cf57b1ad1d13b2afe582d33:

  media: v4l2-compat-ioctl32: better document the code (2018-04-20 08:24:13 
-0400)

are available in the Git repository at:

  git://linuxtv.org/pinchartl/media.git v4l2/vsp1/bru-brs

for you to fetch changes up to 5c0a8b4dfadee010a68b88d82b28f09f373faf86:

  v4l: vsp1: Rename BRU to BRx (2018-04-22 14:11:06 +0300)


Laurent Pinchart (15):
  v4l: vsp1: Don't start/stop media pipeline for DRM
  v4l: vsp1: Remove unused field from vsp1_drm_pipeline structure
  v4l: vsp1: Store pipeline pointer in vsp1_entity
  v4l: vsp1: Use vsp1_entity.pipe to check if entity belongs to a pipeline
  v4l: vsp1: Share duplicated DRM pipeline configuration code
  v4l: vsp1: Move DRM atomic commit pipeline setup to separate function
  v4l: vsp1: Setup BRU at atomic commit time
  v4l: vsp1: Replace manual DRM pipeline input setup in vsp1_du_setup_lif
  v4l: vsp1: Move DRM pipeline output setup code to a function
  v4l: vsp1: Turn frame end completion status into a bitfield
  v4l: vsp1: Add per-display list internal completion notification support
  v4l: vsp1: Generalize detection of entity removal from DRM pipeline
  v4l: vsp1: Assign BRU and BRS to pipelines dynamically
  v4l: vsp1: Add BRx dynamic assignment debugging messages
  v4l: vsp1: Rename BRU to BRx

 drivers/media/platform/vsp1/Makefile   |   2 +-
 drivers/media/platform/vsp1/vsp1.h |   6 +-
 drivers/media/platform/vsp1/{vsp1_bru.c => vsp1_brx.c} | 202 +++---
 drivers/media/platform/vsp1/{vsp1_bru.h => vsp1_brx.h} |  18 +-
 drivers/media/platform/vsp1/vsp1_dl.c  |  45 +-
 drivers/media/platform/vsp1/vsp1_dl.h  |   7 +-
 drivers/media/platform/vsp1/vsp1_drm.c | 828 +--
 drivers/media/platform/vsp1/vsp1_drm.h |  16 +-
 drivers/media/platform/vsp1/vsp1_drv.c |   8 +-
 drivers/media/platform/vsp1/vsp1_entity.h  |   2 +
 drivers/media/platform/vsp1/vsp1_histo.c   |   2 +-
 drivers/media/platform/vsp1/vsp1_histo.h   |   3 -
 drivers/media/platform/vsp1/vsp1_pipe.c|  53 +-
 drivers/media/platform/vsp1/vsp1_pipe.h|   6 +-
 drivers/media/platform/vsp1/vsp1_rpf.c |  12 +-
 drivers/media/platform/vsp1/vsp1_rwpf.h|   4 +-
 drivers/media/platform/vsp1/vsp1_video.c   |  39 +-
 drivers/media/platform/vsp1/vsp1_wpf.c |   8 +-
 18 files changed, 718 insertions(+), 543 deletions(-)
 rename drivers/media/platform/vsp1/{vsp1_bru.c => vsp1_brx.c} (63%)
 rename drivers/media/platform/vsp1/{vsp1_bru.h => vsp1_brx.h} (66%)

-- 
Regards,

Laurent Pinchart





Re: [PATCH 04/15] media: pxa_camera: remove the dmaengine compat need

2018-04-22 Thread Hans Verkuil
On 04/02/2018 04:26 PM, Robert Jarzmik wrote:
> From: Robert Jarzmik 
> 
> As the pxa architecture switched towards the dmaengine slave map, the
> old compatibility mechanism to acquire the dma requestor line number and
> priority are not needed anymore.
> 
> This patch simplifies the dma resource acquisition, using the more
> generic function dma_request_slave_channel().
> 
> Signed-off-by: Robert Jarzmik 

Acked-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/pxa_camera.c | 22 +++---
>  1 file changed, 3 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/media/platform/pxa_camera.c 
> b/drivers/media/platform/pxa_camera.c
> index c71a00736541..4c82d1880753 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2357,8 +2357,6 @@ static int pxa_camera_probe(struct platform_device 
> *pdev)
>   .src_maxburst = 8,
>   .direction = DMA_DEV_TO_MEM,
>   };
> - dma_cap_mask_t mask;
> - struct pxad_param params;
>   char clk_name[V4L2_CLK_NAME_SIZE];
>   int irq;
>   int err = 0, i;
> @@ -2432,34 +2430,20 @@ static int pxa_camera_probe(struct platform_device 
> *pdev)
>   pcdev->base = base;
>  
>   /* request dma */
> - dma_cap_zero(mask);
> - dma_cap_set(DMA_SLAVE, mask);
> - dma_cap_set(DMA_PRIVATE, mask);
> -
> - params.prio = 0;
> - params.drcmr = 68;
> - pcdev->dma_chans[0] =
> - dma_request_slave_channel_compat(mask, pxad_filter_fn,
> -  , >dev, "CI_Y");
> + pcdev->dma_chans[0] = dma_request_slave_channel(>dev, "CI_Y");
>   if (!pcdev->dma_chans[0]) {
>   dev_err(>dev, "Can't request DMA for Y\n");
>   return -ENODEV;
>   }
>  
> - params.drcmr = 69;
> - pcdev->dma_chans[1] =
> - dma_request_slave_channel_compat(mask, pxad_filter_fn,
> -  , >dev, "CI_U");
> + pcdev->dma_chans[1] = dma_request_slave_channel(>dev, "CI_U");
>   if (!pcdev->dma_chans[1]) {
>   dev_err(>dev, "Can't request DMA for Y\n");
>   err = -ENODEV;
>   goto exit_free_dma_y;
>   }
>  
> - params.drcmr = 70;
> - pcdev->dma_chans[2] =
> - dma_request_slave_channel_compat(mask, pxad_filter_fn,
> -  , >dev, "CI_V");
> + pcdev->dma_chans[2] = dma_request_slave_channel(>dev, "CI_V");
>   if (!pcdev->dma_chans[2]) {
>   dev_err(>dev, "Can't request DMA for V\n");
>   err = -ENODEV;
> 



Re: [PATCH 04/15] media: pxa_camera: remove the dmaengine compat need

2018-04-22 Thread Hans Verkuil
On 04/21/2018 09:27 PM, Robert Jarzmik wrote:
> Robert Jarzmik  writes:
> 
>> From: Robert Jarzmik 
>>
>> As the pxa architecture switched towards the dmaengine slave map, the
>> old compatibility mechanism to acquire the dma requestor line number and
>> priority are not needed anymore.
>>
>> This patch simplifies the dma resource acquisition, using the more
>> generic function dma_request_slave_channel().
>>
>> Signed-off-by: Robert Jarzmik 
>> ---
>>  drivers/media/platform/pxa_camera.c | 22 +++---
>>  1 file changed, 3 insertions(+), 19 deletions(-)
> Hans, could I have your ack please ?

Done.

Hans

> 
> Cheers.
> 
> --
> Robert
> 
> PS: The submitted patch
>>
>> diff --git a/drivers/media/platform/pxa_camera.c 
>> b/drivers/media/platform/pxa_camera.c
>> index c71a00736541..4c82d1880753 100644
>> --- a/drivers/media/platform/pxa_camera.c
>> +++ b/drivers/media/platform/pxa_camera.c
>> @@ -2357,8 +2357,6 @@ static int pxa_camera_probe(struct platform_device 
>> *pdev)
>>  .src_maxburst = 8,
>>  .direction = DMA_DEV_TO_MEM,
>>  };
>> -dma_cap_mask_t mask;
>> -struct pxad_param params;
>>  char clk_name[V4L2_CLK_NAME_SIZE];
>>  int irq;
>>  int err = 0, i;
>> @@ -2432,34 +2430,20 @@ static int pxa_camera_probe(struct platform_device 
>> *pdev)
>>  pcdev->base = base;
>>  
>>  /* request dma */
>> -dma_cap_zero(mask);
>> -dma_cap_set(DMA_SLAVE, mask);
>> -dma_cap_set(DMA_PRIVATE, mask);
>> -
>> -params.prio = 0;
>> -params.drcmr = 68;
>> -pcdev->dma_chans[0] =
>> -dma_request_slave_channel_compat(mask, pxad_filter_fn,
>> - , >dev, "CI_Y");
>> +pcdev->dma_chans[0] = dma_request_slave_channel(>dev, "CI_Y");
>>  if (!pcdev->dma_chans[0]) {
>>  dev_err(>dev, "Can't request DMA for Y\n");
>>  return -ENODEV;
>>  }
>>  
>> -params.drcmr = 69;
>> -pcdev->dma_chans[1] =
>> -dma_request_slave_channel_compat(mask, pxad_filter_fn,
>> - , >dev, "CI_U");
>> +pcdev->dma_chans[1] = dma_request_slave_channel(>dev, "CI_U");
>>  if (!pcdev->dma_chans[1]) {
>>  dev_err(>dev, "Can't request DMA for Y\n");
>>  err = -ENODEV;
>>  goto exit_free_dma_y;
>>  }
>>  
>> -params.drcmr = 70;
>> -pcdev->dma_chans[2] =
>> -dma_request_slave_channel_compat(mask, pxad_filter_fn,
>> - , >dev, "CI_V");
>> +pcdev->dma_chans[2] = dma_request_slave_channel(>dev, "CI_V");
>>  if (!pcdev->dma_chans[2]) {
>>  dev_err(>dev, "Can't request DMA for V\n");
>>  err = -ENODEV;



[PATCH 3/3] v4l: rcar_fdp1: Fix indentation oddities

2018-04-22 Thread Laurent Pinchart
Indentation is odd in several places, especially when printing messages
to the kernel log. Fix it to match the usual coding style.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/rcar_fdp1.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/rcar_fdp1.c 
b/drivers/media/platform/rcar_fdp1.c
index b13dec3081e5..81e8a761b924 100644
--- a/drivers/media/platform/rcar_fdp1.c
+++ b/drivers/media/platform/rcar_fdp1.c
@@ -949,7 +949,7 @@ static void fdp1_configure_wpf(struct fdp1_ctx *ctx,
u32 rndctl;
 
pstride = q_data->format.plane_fmt[0].bytesperline
-   << FD1_WPF_PSTRIDE_Y_SHIFT;
+   << FD1_WPF_PSTRIDE_Y_SHIFT;
 
if (q_data->format.num_planes > 1)
pstride |= q_data->format.plane_fmt[1].bytesperline
@@ -1143,8 +1143,8 @@ static int fdp1_m2m_job_ready(void *priv)
int dstbufs = 1;
 
dprintk(ctx->fdp1, "+ Src: %d : Dst: %d\n",
-   v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx),
-   v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx));
+   v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx),
+   v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx));
 
/* One output buffer is required for each field */
if (V4L2_FIELD_HAS_BOTH(src_q_data->format.field))
@@ -1282,7 +1282,7 @@ static void fdp1_m2m_device_run(void *priv)
 
fdp1_queue_field(ctx, fbuf);
dprintk(fdp1, "Queued Buffer [%d] last_field:%d\n",
-   i, fbuf->last_field);
+   i, fbuf->last_field);
}
 
/* Queue as many jobs as our data provides for */
@@ -1341,7 +1341,7 @@ static void device_frame_end(struct fdp1_dev *fdp1,
fdp1_job_free(fdp1, job);
 
dprintk(fdp1, "curr_ctx->num_processed %d curr_ctx->translen %d\n",
-   ctx->num_processed, ctx->translen);
+   ctx->num_processed, ctx->translen);
 
if (ctx->num_processed == ctx->translen ||
ctx->aborting) {
@@ -1366,7 +1366,7 @@ static int fdp1_vidioc_querycap(struct file *file, void 
*priv,
strlcpy(cap->driver, DRIVER_NAME, sizeof(cap->driver));
strlcpy(cap->card, DRIVER_NAME, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info),
-   "platform:%s", DRIVER_NAME);
+"platform:%s", DRIVER_NAME);
return 0;
 }
 
@@ -1997,13 +1997,13 @@ static void fdp1_stop_streaming(struct vb2_queue *q)
/* Free smsk_data */
if (ctx->smsk_cpu) {
dma_free_coherent(ctx->fdp1->dev, ctx->smsk_size,
-   ctx->smsk_cpu, ctx->smsk_addr[0]);
+ ctx->smsk_cpu, ctx->smsk_addr[0]);
ctx->smsk_addr[0] = ctx->smsk_addr[1] = 0;
ctx->smsk_cpu = NULL;
}
 
WARN(!list_empty(>fields_queue),
-   "Buffer queue not empty");
+"Buffer queue not empty");
} else {
/* Empty Capture queues (Jobs) */
struct fdp1_job *job;
@@ -2025,10 +2025,10 @@ static void fdp1_stop_streaming(struct vb2_queue *q)
fdp1_field_complete(ctx, ctx->previous);
 
WARN(!list_empty(>fdp1->queued_job_list),
-   "Queued Job List not empty");
+"Queued Job List not empty");
 
WARN(!list_empty(>fdp1->hw_job_list),
-   "HW Job list not empty");
+"HW Job list not empty");
}
 }
 
@@ -2114,7 +2114,7 @@ static int fdp1_open(struct file *file)
 fdp1_ctrl_deint_menu);
 
ctrl = v4l2_ctrl_new_std(>hdl, _ctrl_ops,
-   V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 2, 1, 1);
+V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 2, 1, 1);
if (ctrl)
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
 
@@ -2351,8 +2351,8 @@ static int fdp1_probe(struct platform_device *pdev)
goto release_m2m;
}
 
-   v4l2_info(>v4l2_dev,
-   "Device registered as /dev/video%d\n", vfd->num);
+   v4l2_info(>v4l2_dev, "Device registered as /dev/video%d\n",
+ vfd->num);
 
/* Power up the cells to read HW */
pm_runtime_enable(>dev);
@@ -2371,7 +2371,7 @@ static int fdp1_probe(struct platform_device *pdev)
break;
default:
dev_err(fdp1->dev, "FDP1 Unidentifiable (0x%08x)\n",
-   hw_version);
+   hw_version);
}
 
/* Allow the hw to sleep until an open call puts it to use */
-- 
Regards,

Laurent Pinchart



[PATCH 2/3] v4l: rcar_fdp1: Enable compilation on Gen2 platforms

2018-04-22 Thread Laurent Pinchart
Commit 1d3897143815 ("[media] v4l: rcar_fdp1: add FCP dependency") fixed
a compilation breakage when the optional VIDEO_RENESAS_FCP dependency is
compiled as a module while the rcar_fdp1 driver is built in. As a side
effect it disabled compilation on Gen2 by disallowing the valid
combination ARCH_RENESAS && !VIDEO_RENESAS_FCP. Fix it by handling the
dependency the same way the vsp1 driver did in commit 199946731fa4
("[media] vsp1: clarify FCP dependency").

Fixes: 1d3897143815 ("[media] v4l: rcar_fdp1: add FCP dependency")
Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 621d63b2001d..81c3ab95c050 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -397,7 +397,7 @@ config VIDEO_RENESAS_FDP1
tristate "Renesas Fine Display Processor"
depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
depends on ARCH_RENESAS || COMPILE_TEST
-   depends on (!ARCH_RENESAS && !VIDEO_RENESAS_FCP) || VIDEO_RENESAS_FCP
+   depends on (!ARM64 && !VIDEO_RENESAS_FCP) || VIDEO_RENESAS_FCP
select VIDEOBUF2_DMA_CONTIG
select V4L2_MEM2MEM_DEV
---help---
-- 
Regards,

Laurent Pinchart



[PATCH 1/3] v4l: rcar_fdp1: Change platform dependency to ARCH_RENESAS

2018-04-22 Thread Laurent Pinchart
From: Geert Uytterhoeven 

The Renesas Fine Display Processor driver is used on Renesas R-Car SoCs
only.  Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce
ARCH_RENESAS") is ARCH_RENESAS a more appropriate platform dependency
than the legacy ARCH_SHMOBILE, hence use the former.

This will allow to drop ARCH_SHMOBILE on ARM and ARM64 in the near
future.

Signed-off-by: Geert Uytterhoeven 
Acked-by: Laurent Pinchart 
Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index c7a1cf8a1b01..621d63b2001d 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -396,7 +396,7 @@ config VIDEO_SH_VEU
 config VIDEO_RENESAS_FDP1
tristate "Renesas Fine Display Processor"
depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
-   depends on ARCH_SHMOBILE || COMPILE_TEST
+   depends on ARCH_RENESAS || COMPILE_TEST
depends on (!ARCH_RENESAS && !VIDEO_RENESAS_FCP) || VIDEO_RENESAS_FCP
select VIDEOBUF2_DMA_CONTIG
select V4L2_MEM2MEM_DEV
-- 
Regards,

Laurent Pinchart



[PATCH 0/3] R-Car Gen2 support for FDP1

2018-04-22 Thread Laurent Pinchart
Hello,

This small patch series improves support of the FDP1 on R-Car Gen2 platforms
by enabling compilation without requiring the Gen3-only FCP dependency.

As the Kconfig change (2/3) conflicts with a patch recently posted by Geert I
have included it in the series as 1/3. Patch 3/3 fixes indentation oddities I
have run across during development.

Geert Uytterhoeven (1):
  v4l: rcar_fdp1: Change platform dependency to ARCH_RENESAS

Laurent Pinchart (2):
  v4l: rcar_fdp1: Enable compilation on Gen2 platforms
  v4l: rcar_fdp1: Fix indentation oddities

 drivers/media/platform/Kconfig |  4 ++--
 drivers/media/platform/rcar_fdp1.c | 28 ++--
 2 files changed, 16 insertions(+), 16 deletions(-)

-- 
Regards,

Laurent Pinchart



Re: [PATCH stable v4.15 1/3] media: staging: lirc_zilog: broken reference counting

2018-04-22 Thread Greg KH
On Mon, Apr 16, 2018 at 10:15:28AM +0100, Sean Young wrote:
> On Mon, Apr 16, 2018 at 10:50:15AM +0200, Greg KH wrote:
> > On Mon, Apr 16, 2018 at 09:43:45AM +0100, Sean Young wrote:
> > > On Mon, Apr 16, 2018 at 09:52:28AM +0200, Greg KH wrote:
> > > > What is the git commit id of this patch, and the other patches in this
> > > > series and the 4.14 patch series that you sent out?
> > > 
> > > lirc_zilog was dropped in v4.16, so this can't be patched upstream.
> > 
> > Ah you are right, should we just ditch them here as well as they
> > obviously do not work? :)
> > 
> > > > Please read:
> > > > 
> > > > https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> > > > for how to do this in a way that I can pick them up.
> > > 
> > > These patches have been tested with different types of hardware. Is there
> > > anything else I can do to get these patches included?
> > 
> > When submitting patches to stable, you need to be explicit as to why
> > they are needed, and if they are not upstream, why not.
> > 
> > In this case, for obviously broken code that is not used anymore (as
> > it is gone in 4.16), why don't we just take the patch that removed the
> > driver to the stable trees as well?
> 
> Well in v4.16 the ir-kbd-i2c.c driver can do what the lirc_zilog does in
> v4.15 (and earlier), so it wasn't ditched as such. It's a case of replaced
> by mainline.
> 
> Since I was getting bug reports on it, there must be users of the lirc_zilog
> driver.
> 
> That being said, the old lirc_dev and lirc_zilog is pretty awful code.

Ok, I've queued these up for 4.14.y now.  4.15 is end-of-life, so I
can't apply these patches there, sorry.

greg k-h


Re: Grant

2018-04-22 Thread M. M. Fridman
I Mikhail Fridman. has selected you specially as one of my beneficiaries
for my Charitable Donation, Just as I have declared on May 23, 2016 to give
my fortune as charity.

Check the link below for confirmation:

http://www.ibtimes.co.uk/russias-second-wealthiest-man-mikhail-fridman-plans-leaving-14-2bn-fortune-charity-1561604

Reply as soon as possible with further directives.

Best Regards,
Mikhail Fridman.


Re: [PATCH 3/8] [media] v4l: rcar_fdp1: Change platform dependency to ARCH_RENESAS

2018-04-22 Thread Laurent Pinchart
Hi Geert,

On Saturday, 21 April 2018 11:07:11 EEST Laurent Pinchart wrote:
> On Friday, 20 April 2018 16:28:29 EEST Geert Uytterhoeven wrote:
> > The Renesas Fine Display Processor driver is used on Renesas R-Car SoCs
> > only.  Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce
> > ARCH_RENESAS") is ARCH_RENESAS a more appropriate platform dependency
> > than the legacy ARCH_SHMOBILE, hence use the former.
> > 
> > This will allow to drop ARCH_SHMOBILE on ARM and ARM64 in the near
> > future.
> > 
> > Signed-off-by: Geert Uytterhoeven 
> 
> Acked-by: Laurent Pinchart 
> 
> How would you like to get this merged ?

Unless you would like to merge the whole series in one go, I'll take this in 
my tree as I have a conflicting patch I would like to submit for v4.18.

> > ---
> > 
> >  drivers/media/platform/Kconfig | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/platform/Kconfig
> > b/drivers/media/platform/Kconfig index f9235e8f8e962d2e..7ad4725f9d1f9627
> > 100644
> > --- a/drivers/media/platform/Kconfig
> > +++ b/drivers/media/platform/Kconfig
> > @@ -396,7 +396,7 @@ config VIDEO_SH_VEU
> >  config VIDEO_RENESAS_FDP1
> > tristate "Renesas Fine Display Processor"
> > depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
> > -   depends on ARCH_SHMOBILE || COMPILE_TEST
> > +   depends on ARCH_RENESAS || COMPILE_TEST
> > depends on (!ARCH_RENESAS && !VIDEO_RENESAS_FCP) || VIDEO_RENESAS_FCP
> > select VIDEOBUF2_DMA_CONTIG
> > select V4L2_MEM2MEM_DEV

-- 
Regards,

Laurent Pinchart