cron job: media_tree daily build: ERRORS

2017-05-26 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:   Sat May 27 05:00:25 CEST 2017
media-tree git hash:36bcba973ad478042d1ffc6e89afd92e8bd17030
media_build git hash:   c8dfc17d6d049d79497c78737625f6ea3b08c456
v4l-utils git hash: d16a17abd1d8d7885ca2f44fb295035278baa89c
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0-3553-g78b2ea6
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.9.0-164

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

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH v5 3/7] media: i2c: max2175: Add MAX2175 support

2017-05-26 Thread Sakari Ailus
On Fri, May 26, 2017 at 02:47:32PM +, Ramesh Shanmugasundaram wrote:
> Hi Sakari,
> 
> Thanks for the review comments on the patches. Sorry for the late response
> as I was caught up with another work.

No worries.

> 
> I will incorporate your comments and rebase it on top of your branch. I
> see it is not there in media-tree master yet. Please let me know if there
> is a change in plan.

I've sent a pull request to Mauro here and my expectation is it'll reach
media tree master in not too distant future:



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


Re: [PATCH] davinci: vpif_capture: fix default pixel format for BT.656/BT.1120 video

2017-05-26 Thread Kevin Hilman
Sekhar Nori  writes:

> For both BT.656 and BT.1120 video, the pixel format
> used by VPIF is Y/CbCr 4:2:2 in semi-planar format
> (Luma in one plane and Chroma in another). This
> corresponds to NV16 pixel format.
>
> This is documented in section 36.2.3 of OMAP-L138
> Technical Reference Manual, SPRUH77A.
>
> The VPIF driver incorrectly sets the default format
> to V4L2_PIX_FMT_YUV422P. Fix it.
>
> Reported-by: Alejandro Hernandez 
> Signed-off-by: Sekhar Nori 

Acked-by: Kevin Hilman 


Re: [PATCH v2 1/2] media: entity: Add pad_from_fwnode entity operation

2017-05-26 Thread Sakari Ailus
Hejssan,

On Wed, May 24, 2017 at 04:07:36PM +0200, Niklas Söderlund wrote:
> Hi Sakari,
> 
> Thanks for your feedback.
> 
> On 2017-05-24 16:21:37 +0300, Sakari Ailus wrote:
> > Hi Niklas,
> > 
> > On Wed, May 24, 2017 at 02:09:06AM +0200, Niklas Söderlund wrote:
> > > From: Niklas Söderlund 
> > > 
> > > The optional operation can be used by entities to report how it maps its
> > > fwnode endpoints to media pad numbers. This is useful for devices which
> > > require advanced mappings of pads.
> > > 
> > > Signed-off-by: Niklas Söderlund 
> > > ---
> > >  include/media/media-entity.h | 6 ++
> > >  1 file changed, 6 insertions(+)
> > > 
> > > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > > index c7c254c5bca1761b..2aea22b0409d1070 100644
> > > --- a/include/media/media-entity.h
> > > +++ b/include/media/media-entity.h
> > > @@ -21,6 +21,7 @@
> > >  
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -171,6 +172,9 @@ struct media_pad {
> > >  
> > >  /**
> > >   * struct media_entity_operations - Media entity operations
> > > + * @pad_from_fwnode: Return the pad number based on a fwnode 
> > > endpoint.
> > > + *   This operation can be used to map a fwnode to a
> > > + *   media pad number. Optional.
> > >   * @link_setup:  Notify the entity of link changes. The 
> > > operation can
> > >   *   return an error, in which case link setup will 
> > > be
> > >   *   cancelled. Optional.
> > > @@ -184,6 +188,8 @@ struct media_pad {
> > >   *mutex held.
> > >   */
> > >  struct media_entity_operations {
> > > + int (*pad_from_fwnode)(struct fwnode_endpoint *endpoint,
> > > +unsigned int *pad);
> > 
> > Hmm. How about calling this get_fwnode_pad for instance? I wonder what
> > others think.
> 
> I'm OK with this name change, will update for next version.
> 
> > 
> > You could just return the pad number still, and a negative value on error. I
> > think we won't have more than INT_MAX pads. :-)
> 
> I did that at first but then I remembered all the review comments I have 
> gotten earlier about using int as the type for pads :-) If you and 
> others agree in this case returning the pad as int or a negative value 
> as error I have no problem chaining this for the next version.

unsigned int was proposed for there was no need for negative values. In this
case there is.

I don't really have a strong opinion either way. I wonder what Hans or
Laurent thinks.

-- 
Regards,

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


[PATCH v3 1/1] [media] i2c: add support for OV13858 sensor

2017-05-26 Thread Hyungwoo Yang
This patch adds driver for Omnivision's ov13858
sensor, the driver supports following features:

- manual exposure/analog gain
- two link frequencies
- VBLANK support
- media controller support
- runtime pm support

Signed-off-by: Hyungwoo Yang 
---
 drivers/media/i2c/Kconfig   |8 +
 drivers/media/i2c/Makefile  |1 +
 drivers/media/i2c/ov13858.c | 1738 +++
 3 files changed, 1747 insertions(+)
 create mode 100644 drivers/media/i2c/ov13858.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index fd181c9..f8c5cca 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -589,6 +589,14 @@ config VIDEO_OV9650
  This is a V4L2 sensor-level driver for the Omnivision
  OV9650 and OV9652 camera sensors.
 
+config VIDEO_OV13858
+   tristate "OmniVision OV13858 sensor support"
+   depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV13858 camera.
+
 config VIDEO_VS6624
tristate "ST VS6624 sensor support"
depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 62323ec..3f4dc02 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
 obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
 obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
+obj-$(CONFIG_VIDEO_OV13858) += ov13858.o
 obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o
 obj-$(CONFIG_VIDEO_MT9M111) += mt9m111.o
 obj-$(CONFIG_VIDEO_MT9P031) += mt9p031.o
diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c
new file mode 100644
index 000..58dd9c7
--- /dev/null
+++ b/drivers/media/i2c/ov13858.c
@@ -0,0 +1,1738 @@
+/*
+ * Copyright (c) 2017 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define OV13858_REG_VALUE_08BIT1
+#define OV13858_REG_VALUE_16BIT2
+#define OV13858_REG_VALUE_24BIT3
+
+#define OV13858_REG_MODE_SELECT0x0100
+#define OV13858_MODE_STANDBY   0x00
+#define OV13858_MODE_STREAMING 0x01
+
+#define OV13858_REG_SOFTWARE_RST   0x0103
+#define OV13858_SOFTWARE_RST   0x01
+
+/* PLL1 generates PCLK and MIPI_PHY_CLK */
+#define OV13858_REG_PLL1_CTRL_00x0300
+#define OV13858_REG_PLL1_CTRL_10x0301
+#define OV13858_REG_PLL1_CTRL_20x0302
+#define OV13858_REG_PLL1_CTRL_30x0303
+#define OV13858_REG_PLL1_CTRL_40x0304
+#define OV13858_REG_PLL1_CTRL_50x0305
+
+/* PLL2 generates DAC_CLK, SCLK and SRAM_CLK */
+#define OV13858_REG_PLL2_CTRL_B0x030b
+#define OV13858_REG_PLL2_CTRL_C0x030c
+#define OV13858_REG_PLL2_CTRL_D0x030d
+#define OV13858_REG_PLL2_CTRL_E0x030e
+#define OV13858_REG_PLL2_CTRL_F0x030f
+#define OV13858_REG_PLL2_CTRL_12   0x0312
+#define OV13858_REG_MIPI_SC_CTRL0  0x3016
+#define OV13858_REG_MIPI_SC_CTRL1  0x3022
+
+/* Chip ID */
+#define OV13858_REG_CHIP_ID0x300a
+#define OV13858_CHIP_ID0x00d855
+
+/* V_TIMING internal */
+#define OV13858_REG_VTS0x380e
+#define OV13858_VTS_30FPS  0x0c8e /* 30 fps */
+#define OV13858_VTS_60FPS  0x0648 /* 60 fps */
+#define OV13858_VTS_MAX0x7fff
+#define OV13858_VBLANK_MIN 56
+
+/* Exposure control */
+#define OV13858_REG_EXPOSURE   0x3500
+#define OV13858_EXPOSURE_MIN   4
+#define OV13858_EXPOSURE_MAX   (OV13858_VTS_MAX - 8)
+#define OV13858_EXPOSURE_STEP  1
+#define OV13858_EXPOSURE_DEFAULT   0x640
+
+/* Analog gain control */
+#define OV13858_REG_ANALOG_GAIN0x3508
+#define OV13858_ANA_GAIN_MIN   0
+#define OV13858_ANA_GAIN_MAX   0x1fff
+#define OV13858_ANA_GAIN_STEP  1
+#define OV13858_ANA_GAIN_DEFAULT   0x80
+
+/* Number of frames to skip */
+#define OV13858_NUM_OF_SKIP_FRAMES 2
+
+struct ov13858_reg {
+   u16 address;
+   u8 val;
+};
+
+struct ov13858_reg_list {
+   u32 num_of_regs;
+   const struct ov13858_reg *regs;
+};
+
+/* Link frequency config */
+struct ov13858_link_freq_config {
+   u32 

[regression] Build failure on ubuntu 16.04 LTS

2017-05-26 Thread Vincent McIntyre
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"

$ uname -a
Linux testbox 4.8.0-53-generic #56~16.04.1-Ubuntu SMP Tue May 16
01:18:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ git remote -v
origin  git://linuxtv.org/media_build.git (fetch)
origin  git://linuxtv.org/media_build.git (push)

$ git log -1
commit c8dfc17d6d049d79497c78737625f6ea3b08c456
Author: Hans Verkuil 
Date:   Mon May 22 09:11:11 2017 +0200

Don't build atomisp crap

Signed-off-by: Hans Verkuil 

The attached log file has the failure. This build was done with a
fresh git clone.  I did a quick grep of the tree and the only place I
find cec_devnode_register is in the module that fails to build,
cec-core.c.

Any advice welcome.
Vince
**
* Start building *
**
make -C /home/me/git/clones/media_build/v4l allyesconfig
make[1]: Entering directory '/home/me/git/clones/media_build/v4l'
No version yet, using 4.8.0-53-generic
make[2]: Entering directory '/home/me/git/clones/media_build/linux'
Syncing with dir ../media/
Applying patches for kernel 4.8.0-53-generic
patch -s -f -N -p1 -i ../backports/api_version.patch
patch -s -f -N -p1 -i ../backports/pr_fmt.patch
patch -s -f -N -p1 -i ../backports/debug.patch
patch -s -f -N -p1 -i ../backports/drx39xxj.patch
patch -s -f -N -p1 -i ../backports/v4.10_sched_signal.patch
patch -s -f -N -p1 -i ../backports/v4.10_fault_page.patch
patch -s -f -N -p1 -i ../backports/v4.10_refcount.patch
patch -s -f -N -p1 -i ../backports/v4.9_mm_address.patch
patch -s -f -N -p1 -i ../backports/v4.9_dvb_net_max_mtu.patch
patch -s -f -N -p1 -i ../backports/v4.9_ktime_cleanups.patch
patch -s -f -N -p1 -i ../backports/v4.8_user_pages_flag.patch
Patched drivers/media/dvb-core/dvbdev.c
Patched drivers/media/v4l2-core/v4l2-dev.c
Patched drivers/media/rc/rc-main.c
Syncing with dir ../media/
make[2]: Leaving directory '/home/me/git/clones/media_build/linux'
./scripts/make_kconfig.pl /lib/modules/4.8.0-53-generic/build /lib/modules/4.8.0-53-generic/build 1
Preparing to compile for kernel version 4.8.0

***WARNING:*** You do not have the full kernel sources installed.
This does not prevent you from building the v4l-dvb tree if you have the
kernel headers, but the full kernel source may be required in order to use
make menuconfig / xconfig / qconfig.

If you are experiencing problems building the v4l-dvb tree, please try
building against a vanilla kernel before reporting a bug.

Vanilla kernels are available at http://kernel.org.
On most distros, this will compile a newly downloaded kernel:

cp /boot/config-`uname -r` /.config
cd 
make all modules_install install

Please see your distro's web site for instructions to build a new kernel.

WARNING: This is the V4L/DVB backport tree, with experimental drivers
 backported to run on legacy kernels from the development tree at:
http://git.linuxtv.org/media-tree.git.
 It is generally safe to use it for testing a new driver or
 feature, but its usage on production environments is risky.
 Don't use it in production. You've been warned.
INTEL_ATOMISP: Requires at least kernel 9.255.255
Created default (all yes) .config file
./scripts/fix_kconfig.pl
make[1]: Leaving directory '/home/me/git/clones/media_build/v4l'
make -C /home/me/git/clones/media_build/v4l 
make[1]: Entering directory '/home/me/git/clones/media_build/v4l'
scripts/make_makefile.pl
Can't handle includes! In ../linux/drivers/staging/media/atomisp/pci/atomisp2/css2400/Makefile at scripts/make_makefile.pl line 109,  line 4.
./scripts/make_myconfig.pl
perl scripts/make_config_compat.pl /lib/modules/4.8.0-53-generic/build ./.myconfig ./config-compat.h
creating symbolic links...
make -C firmware prep
make[2]: Entering directory '/home/me/git/clones/media_build/v4l/firmware'
make[2]: Leaving directory '/home/me/git/clones/media_build/v4l/firmware'
make -C firmware
make[2]: Entering directory '/home/me/git/clones/media_build/v4l/firmware'
  CC  ihex2fw
Generating vicam/firmware.fw
Generating ttusb-budget/dspbootcode.bin
Generating cpia2/stv0672_vp4.bin
Generating av7110/bootcode.bin
make[2]: Leaving directory '/home/me/git/clones/media_build/v4l/firmware'
Kernel build directory is /lib/modules/4.8.0-53-generic/build
make -C ../linux apply_patches
make[2]: Entering directory '/home/me/git/clones/media_build/linux'
Syncing with dir ../media/
Patches for 4.8.0-53-generic already applied.
make[2]: Leaving directory '/home/me/git/clones/media_build/linux'
make -C /lib/modules/4.8.0-53-generic/build SUBDIRS=/home/me/git/clones/media_build/v4l  modules
make[2]: Entering directory '/usr/src/linux-headers-4.8.0-53-generic'
  CC [M]  /home/me/git/clones/media_build/v4l/cec-core.o
/home/me/git/clones/media_build/v4l/cec-core.c: In function 'cec_devnode_register':
/home/me/git/clones/media_build/v4l/cec-core.c:142:8: error: implicit 

RE: [PATCH 1/1] [media] i2c: add support for OV13858 sensor

2017-05-26 Thread Yang, Hyungwoo
Hi Sakari,

I've submitted V2 yesterday. If possible, can you review that one also ?
I'm learning many things from your review comments.

I think in V2, I've addressed most of comments except raw bayer format.

For ray bayer format, for now, I intentionally don't support crop since it 
requires more complexity to meet request from _set_pad_format() while keeping 
FOV for the resolutions with the same ratio(4:3 or 16:9).
Yes, it is hacky but I thought it's OK unless there's a need to support crop. 
Hm. I'm thinking drop "bayer order change" since it is not that meaningful. 
Should I ?

For VBLANK, I realized I made wrong comments just after I send it. Yeas, it 
shouldn't be read-only. So you can see that VBLANK I added in V2 is NOT 
read-only. 

Thanks,
Hyungwoo


> Hi Hyungwoo,
> 
> On Wed, May 24, 2017 at 11:13:50PM +, Yang, Hyungwoo wrote:
> ...
> > > > +static inline int ov13858_write_reg_list(struct ov13858 *ov13858,
> > > 
> > > I'd drop inline.
> > 
> > if it's not mandatory for upstream, I prefer to keep inline for people 
> > who want to port this with a not-good-compiler. Is it mandatory ?
> 
> I don't think you'd really lose anything if the compiler didn't inline it.
> It's a non-issue anyway.
> 
> ...
> 
> > > > +/*
> > > > + * Change the bayer order to meet the requested one.
> > > > + */
> > > > +static int ov13858_apply_bayer_order(struct ov13858 *ov13858) {
> > > > +   int ret;
> > > > +
> > > > +   switch (ov13858->cur_bayer_format) {
> > > > +   case MEDIA_BUS_FMT_SGRBG10_1X10:
> > > > +   break;
> > > > +   case MEDIA_BUS_FMT_SRGGB10_1X10:
> > > > +   return ov13858_increase_offset(ov13858, 
> > > > OV13858_REG_H_OFFSET);
> > > > +   case MEDIA_BUS_FMT_SGBRG10_1X10:
> > > > +   ret = ov13858_increase_offset(ov13858, 
> > > > OV13858_REG_H_OFFSET);
> > > 
> > > The bayer pixel order is defined by cropping the pixel array. If the 
> > > sensor can do that, you should implement support for the crop selection 
> > > rectangle instead.
> > 
> > Sorry, I'm new to imaging world but, as you can see, bayer order in 
> > this sensor IS DEFINED by both cropping and offset(where you start to 
> > read). Is there a strict (implicit or explicit) rule or specific 
> > reason that we should use only crop to apply expected bayer order, 
> > even though the bayer order in the sensor is defined by both crop and 
> > offset ?
> > 
> > Anyway, I changed H_/V_OFFSET(0x3810, 0x3812) to 
> > H_/V_CROP_START(0x3800,
> > 0x3802) with no changes in initial values.
> 
> The CROP selection rectangle is the interface to configure crop an area from 
> the parent rectangle (NATIVE_SIZE in this case). Using the format to change 
> cropping in pre-defined ways is quite hackish.
> 
> ...
> 
> > > > +/* Exposure control */
> > > > +static int ov13858_update_exposure(struct ov13858 *ov13858,
> > > > +  struct v4l2_ctrl *ctrl)
> > > > +{
> > > > +   int ret;
> > > > +   u32 exposure, new_vts = 0;
> > > > +
> > > > +   exposure = ctrl->val;
> > > > +   if (exposure > ov13858->cur_mode->vts - 8)
> > > > +   new_vts = exposure + 8;
> > > > +   else
> > > > +   new_vts = ov13858->cur_mode->vts;
> > > 
> > > Instead of changing the vertical blanking interval implicitly, could 
> > > you do it explicitly though the VBLANK control instead?
> > > 
> > > As you do already control the vertical sync and provide the pixel 
> > > rate control, how about adding a HBLANK control as well? I suppose 
> > > it could be added later on as well. And presumably will be read only.
> > 
> > I'll introduce VBLANK control with READ ONLY and the value of the 
> > control will be updated here.
> 
> HBLANK would be read-only since the register list that you have might contain 
> dependencies to the horizontal blanking so you can't change that.
> The VBLANK control, instead, should not be read-only to allow controlling the 
> frame rate and also controlling the exposure without affecting the frame rate.
> 
> > 
> > > 
> > > > +
> > > > +   ret = ov13858_group_hold_start(ov13858, 0);
> > > > +   if (ret)
> > > > +   return ret;
> > > > +
> > > > +   ret = ov13858_write_reg(ov13858, OV13858_REG_VTS,
> > > > +   OV13858_REG_VALUE_16BIT, new_vts);
> > > > +   if (ret)
> > > > +   return ret;
> > > > +
> > > 
> > > If you want group hold for that, too, we need a new callback (or 
> > > two) for the control handler I believe.
> > 
> > I don't understand wht this means. Can you give me detail ?
> 
> The V4L2 control framework calls the s_ctrl() callback in the driver to set 
> control values. The driver however doesn't know how many controls there will 
> be to set or when the last control of the set would be conveyed to the 
> driver. To use the grouped parameter hold meaningfully this information is 
> needed.
> 
> ...
> 
> > > > +   /* Values of V4L2 

Re: [PATCH 1/1] [media] i2c: add support for OV13858 sensor

2017-05-26 Thread Sakari Ailus
Hi Hyungwoo,

On Wed, May 24, 2017 at 11:13:50PM +, Yang, Hyungwoo wrote:
...
> > > +static inline int ov13858_write_reg_list(struct ov13858 *ov13858,
> > 
> > I'd drop inline.
> 
> if it's not mandatory for upstream, I prefer to keep inline for people who
> want to port this with a not-good-compiler. Is it mandatory ?

I don't think you'd really lose anything if the compiler didn't inline it.
It's a non-issue anyway.

...

> > > +/*
> > > + * Change the bayer order to meet the requested one.
> > > + */
> > > +static int ov13858_apply_bayer_order(struct ov13858 *ov13858) {
> > > + int ret;
> > > +
> > > + switch (ov13858->cur_bayer_format) {
> > > + case MEDIA_BUS_FMT_SGRBG10_1X10:
> > > + break;
> > > + case MEDIA_BUS_FMT_SRGGB10_1X10:
> > > + return ov13858_increase_offset(ov13858, OV13858_REG_H_OFFSET);
> > > + case MEDIA_BUS_FMT_SGBRG10_1X10:
> > > + ret = ov13858_increase_offset(ov13858, OV13858_REG_H_OFFSET);
> > 
> > The bayer pixel order is defined by cropping the pixel array. If the sensor 
> > can do that, you should implement support for the crop selection rectangle 
> > instead.
> 
> Sorry, I'm new to imaging world but, as you can see, bayer order in this
> sensor IS DEFINED by both cropping and offset(where you start to read). Is
> there a strict (implicit or explicit) rule or specific reason that we
> should use only crop to apply expected bayer order, even though the bayer
> order in the sensor is defined by both crop and offset ?
> 
> Anyway, I changed H_/V_OFFSET(0x3810, 0x3812) to H_/V_CROP_START(0x3800,
> 0x3802) with no changes in initial values.

The CROP selection rectangle is the interface to configure crop an area from
the parent rectangle (NATIVE_SIZE in this case). Using the format to change
cropping in pre-defined ways is quite hackish.

...

> > > +/* Exposure control */
> > > +static int ov13858_update_exposure(struct ov13858 *ov13858,
> > > +struct v4l2_ctrl *ctrl)
> > > +{
> > > + int ret;
> > > + u32 exposure, new_vts = 0;
> > > +
> > > + exposure = ctrl->val;
> > > + if (exposure > ov13858->cur_mode->vts - 8)
> > > + new_vts = exposure + 8;
> > > + else
> > > + new_vts = ov13858->cur_mode->vts;
> > 
> > Instead of changing the vertical blanking interval implicitly, could you
> > do it explicitly though the VBLANK control instead?
> > 
> > As you do already control the vertical sync and provide the pixel rate
> > control, how about adding a HBLANK control as well? I suppose it could
> > be added later on as well. And presumably will be read only.
> 
> I'll introduce VBLANK control with READ ONLY and the value of the control
> will be updated here.

HBLANK would be read-only since the register list that you have might
contain dependencies to the horizontal blanking so you can't change that.
The VBLANK control, instead, should not be read-only to allow controlling
the frame rate and also controlling the exposure without affecting the frame
rate.

> 
> > 
> > > +
> > > + ret = ov13858_group_hold_start(ov13858, 0);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + ret = ov13858_write_reg(ov13858, OV13858_REG_VTS,
> > > + OV13858_REG_VALUE_16BIT, new_vts);
> > > + if (ret)
> > > + return ret;
> > > +
> > 
> > If you want group hold for that, too, we need a new callback (or two)
> > for the control handler I believe.
> 
> I don't understand wht this means. Can you give me detail ?

The V4L2 control framework calls the s_ctrl() callback in the driver to set
control values. The driver however doesn't know how many controls there will
be to set or when the last control of the set would be conveyed to the
driver. To use the grouped parameter hold meaningfully this information is
needed.

...

> > > + /* Values of V4L2 controls will be applied only when power is up */
> > > + if (atomic_read(>dev.power.usage_count) == 0)
> > 
> > I wonder if using pm_runtime_active() would work for this. Checking the
> > usage_count directly does not look like something a driver should be
> > doing.
> 
> Agree, I really wanted to use any helper(accesor) method for this but when
> I checked the pm_runtime_active() it wasn't good enough. Anyway I just
> found better one for this case. I'll not use using usage_count and
> instread of using pm_runtime_get_sync, I'll use pm_runtime_get_if_in_use()

Ah, that seems much better indeed!

> 
> > 
> > > + return 0;
> > > +
> > > + ret = pm_runtime_get_sync(>dev);
> > > + if (ret < 0) {
> > > + pm_runtime_put_noidle(>dev);
> > > + return ret;
> > > + }
> > > +
> > > + ret = 0;
> > > + switch (ctrl->id) {
> > > + case V4L2_CID_ANALOGUE_GAIN:
> > > + ret = ov13858_update_analog_gain(ov13858, ctrl);
> > > + break;
> > > + case V4L2_CID_EXPOSURE:
> > > + ret = ov13858_update_exposure(ov13858, ctrl);
> > > + break;
> > > + default:
> > > + dev_info(>dev,
> > > +  

Re: [patch, libv4l]: add sdlcam example for testing digital still camera functionality

2017-05-26 Thread Pavel Machek
Hi!

> Add simple SDL-based application for capturing photos. Manual
> focus/gain/exposure can be set, flash can be controlled and
> autofocus/autogain can be selected if camera supports that.
> 
> It is already useful for testing autofocus/autogain improvements to
> the libraries on Nokia N900.
> 
> Signed-off-by: Pavel Machek 

Could I get some feedback here, or get you to apply the patch?

Thanks,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH v6] dw9714: Initial driver for dw9714 VCM

2017-05-26 Thread Rajmohan Mani
DW9714 is a 10 bit DAC, designed for linear
control of voice coil motor.

This driver creates a V4L2 subdevice and
provides control to set the desired focus.

Signed-off-by: Rajmohan Mani 
---
Changes in v6:
- Addressed review comments from Sakari on v5 patch
Changes in v5:
- Addressed review comments from Tomasz, Sakari and Sylwester on v4
of this patch
Changes in v4:
- Addressed review comments from Tomasz
Changes in v3:
- Addressed most of the review comments from Sakari
  on v1 of this patch
Changes in v2:
- Addressed review comments from Hans Verkuil
- Fixed a debug message typo
---
 drivers/media/i2c/Kconfig  |  10 ++
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/dw9714.c | 290 +
 3 files changed, 301 insertions(+)
 create mode 100644 drivers/media/i2c/dw9714.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index fd181c9..188ab15 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -300,6 +300,16 @@ config VIDEO_AD5820
  This is a driver for the AD5820 camera lens voice coil.
  It is used for example in Nokia N900 (RX-51).
 
+config VIDEO_DW9714
+   tristate "DW9714 lens voice coil support"
+   depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER
+   depends on VIDEO_V4L2_SUBDEV_API
+   ---help---
+ This is a driver for the DW9714 camera lens voice coil.
+ DW9714 is a 10 bit DAC with 120mA output current sink
+ capability. This is designed for linear control of
+ voice coil motors, controlled via I2C serial interface.
+
 config VIDEO_SAA7110
tristate "Philips SAA7110 video decoder"
depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 62323ec..987bd1f 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
 obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o
 obj-$(CONFIG_VIDEO_SAA6752HS) += saa6752hs.o
 obj-$(CONFIG_VIDEO_AD5820)  += ad5820.o
+obj-$(CONFIG_VIDEO_DW9714)  += dw9714.o
 obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o
 obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o
 obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o
diff --git a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c
new file mode 100644
index 000..1c95314
--- /dev/null
+++ b/drivers/media/i2c/dw9714.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2015--2017 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DW9714_NAME"dw9714"
+#define DW9714_MAX_FOCUS_POS   1023
+/*
+ * This acts as the minimum granularity of lens movement.
+ * Keep this value power of 2, so the control steps can be
+ * uniformly adjusted for gradual lens movement, with desired
+ * number of control steps.
+ */
+#define DW9714_CTRL_STEPS  16
+#define DW9714_CTRL_DELAY_US   1000
+/*
+ * S[3:2] = 0x00, codes per step for "Linear Slope Control"
+ * S[1:0] = 0x00, step period
+ */
+#define DW9714_DEFAULT_S 0x0
+#define DW9714_VAL(data, s) ((data) << 4 | (s))
+
+/* dw9714 device structure */
+struct dw9714_device {
+   struct i2c_client *client;
+   struct v4l2_ctrl_handler ctrls_vcm;
+   struct v4l2_subdev sd;
+   u16 current_val;
+};
+
+static inline struct dw9714_device *to_dw9714_vcm(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl->handler, struct dw9714_device, ctrls_vcm);
+}
+
+static inline struct dw9714_device *sd_to_dw9714_vcm(struct v4l2_subdev 
*subdev)
+{
+   return container_of(subdev, struct dw9714_device, sd);
+}
+
+static int dw9714_i2c_write(struct i2c_client *client, u16 data)
+{
+   int ret;
+   u16 val = cpu_to_be16(data);
+
+   ret = i2c_master_send(client, (const char *), sizeof(val));
+   if (ret != sizeof(val)) {
+   dev_err(>dev, "I2C write fail\n");
+   return -EIO;
+   }
+   return 0;
+}
+
+static int dw9714_t_focus_vcm(struct dw9714_device *dw9714_dev, u16 val)
+{
+   struct i2c_client *client = dw9714_dev->client;
+
+   dw9714_dev->current_val = val;
+
+   return dw9714_i2c_write(client, DW9714_VAL(val, DW9714_DEFAULT_S));
+}
+
+static int dw9714_set_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct dw9714_device *dev_vcm = to_dw9714_vcm(ctrl);
+
+   if (ctrl->id == V4L2_CID_FOCUS_ABSOLUTE)
+   return dw9714_t_focus_vcm(dev_vcm, ctrl->val);
+
+   return 

RE: [PATCH v5] dw9714: Initial driver for dw9714 VCM

2017-05-26 Thread Mani, Rajmohan
Hi Sakari,

> -Original Message-
> From: Sakari Ailus [mailto:sakari.ai...@iki.fi]
> Sent: Friday, May 26, 2017 1:20 AM
> To: Mani, Rajmohan 
> Cc: linux-media@vger.kernel.org; mche...@kernel.org; hverk...@xs4all.nl;
> tf...@chromium.org; s.nawro...@samsung.com; Toivonen, Tuukka
> 
> Subject: Re: [PATCH v5] dw9714: Initial driver for dw9714 VCM
> 
> Hi Rajmohan,
> 
> Thankd for the update. A few more comments I missed earlier.
> 
> On Thu, May 25, 2017 at 06:50:35PM -0700, Rajmohan Mani wrote:
> > DW9714 is a 10 bit DAC, designed for linear control of voice coil
> > motor.
> >
> > This driver creates a V4L2 subdevice and provides control to set the
> > desired focus.
> >
> > Signed-off-by: Rajmohan Mani 
> > ---
> > Changes in v5:
> > - Addressed review comments from Tomasz, Sakari and Sylwester on v4
> > of this patch
> > Changes in v4:
> > - Addressed review comments from Tomasz Changes in v3:
> > - Addressed most of the review comments from Sakari
> >   on v1 of this patch
> > Changes in v2:
> > - Addressed review comments from Hans Verkuil
> > - Fixed a debug message typo
> > - Got rid of a return variable
> > ---
> >  drivers/media/i2c/Kconfig  |   9 ++
> >  drivers/media/i2c/Makefile |   1 +
> >  drivers/media/i2c/dw9714.c | 292
> > +
> >  3 files changed, 302 insertions(+)
> >  create mode 100644 drivers/media/i2c/dw9714.c
> >
> > diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> > index fd181c9..516e2f2 100644
> > --- a/drivers/media/i2c/Kconfig
> > +++ b/drivers/media/i2c/Kconfig
> > @@ -300,6 +300,15 @@ config VIDEO_AD5820
> >   This is a driver for the AD5820 camera lens voice coil.
> >   It is used for example in Nokia N900 (RX-51).
> >
> > +config VIDEO_DW9714
> > +   tristate "DW9714 lens voice coil support"
> > +   depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER &&
> > +VIDEO_V4L2_SUBDEV_API
> 
> This would be better split on two lines.
> 

Ack

> > +   ---help---
> > + This is a driver for the DW9714 camera lens voice coil.
> > + DW9714 is a 10 bit DAC with 120mA output current sink
> > + capability. This is designed for linear control of
> > + voice coil motors, controlled via I2C serial interface.
> > +
> >  config VIDEO_SAA7110
> > tristate "Philips SAA7110 video decoder"
> > depends on VIDEO_V4L2 && I2C
> > diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> > index 62323ec..987bd1f 100644
> > --- a/drivers/media/i2c/Makefile
> > +++ b/drivers/media/i2c/Makefile
> > @@ -21,6 +21,7 @@ obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
> >  obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o
> >  obj-$(CONFIG_VIDEO_SAA6752HS) += saa6752hs.o
> >  obj-$(CONFIG_VIDEO_AD5820)  += ad5820.o
> > +obj-$(CONFIG_VIDEO_DW9714)  += dw9714.o
> >  obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o
> >  obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o
> >  obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o diff --git
> > a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c new file
> > mode 100644 index 000..22c84de
> > --- /dev/null
> > +++ b/drivers/media/i2c/dw9714.c
> > @@ -0,0 +1,292 @@
> > +/*
> > + * Copyright (c) 2015--2017 Intel Corporation.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License
> > +version
> > + * 2 as published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define DW9714_NAME"dw9714"
> > +#define DW9714_MAX_FOCUS_POS   1023
> > +/*
> > + * This acts as the minimum granularity of lens movement.
> > + * Keep this value power of 2, so the control steps can be
> > + * uniformly adjusted for gradual lens movement, with desired
> > + * number of control steps.
> > + */
> > +#define DW9714_CTRL_STEPS  16
> > +#define DW9714_CTRL_DELAY_US   1000
> > +/*
> > + * S[3:2] = 0x00, codes per step for "Linear Slope Control"
> > + * S[1:0] = 0x00, step period
> > + */
> > +#define DW9714_DEFAULT_S 0x0
> > +#define DW9714_VAL(data, s) ((data) << 4 | (s))
> > +
> > +/* dw9714 device structure */
> > +struct dw9714_device {
> > +   struct i2c_client *client;
> > +   struct v4l2_ctrl_handler ctrls_vcm;
> > +   struct v4l2_subdev sd;
> > +   u16 current_val;
> > +};
> > +
> > +static inline struct dw9714_device *to_dw9714_vcm(struct v4l2_ctrl
> > +*ctrl) {
> > +   return container_of(ctrl->handler, struct dw9714_device, ctrls_vcm);
> > +}
> > +
> > +static inline struct dw9714_device 

[PATCH 10/11] atomisp: remove sh_css_irq - it contains nothing

2017-05-26 Thread Alan Cox
We won't be adding abstractions or moving them here so kill it.

Signed-off-by: Alan Cox 
---
 .../staging/media/atomisp/pci/atomisp2/Makefile|1 -
 .../atomisp/pci/atomisp2/css2400/sh_css_irq.c  |   16 
 2 files changed, 17 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_irq.c

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/Makefile 
b/drivers/staging/media/atomisp/pci/atomisp2/Makefile
index f126a89..93f85d3 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/Makefile
+++ b/drivers/staging/media/atomisp/pci/atomisp2/Makefile
@@ -108,7 +108,6 @@ atomisp-objs += \
css2400/sh_css_metadata.o \
css2400/base/refcount/src/refcount.o \
css2400/base/circbuf/src/circbuf.o \
-   css2400/sh_css_irq.o \
css2400/camera/pipe/src/pipe_binarydesc.o \
css2400/camera/pipe/src/pipe_util.o \
css2400/camera/pipe/src/pipe_stagedesc.o \
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_irq.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_irq.c
deleted file mode 100644
index 37e954a..000
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_irq.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-/* This file will contain the code to implement the functions declared in 
ia_css_irq.h
-   and associated helper functions */



[PATCH 11/11] atomisp: de-duplicate sh_css_mmu_set_page_table_base_index

2017-05-26 Thread Alan Cox
Between the ISP2400 and ISP2401 code base this function moved file. The merge
of the drivers left us with two version in ifdefs. Resolve this down to a
single copy.

Signed-off-by: Alan Cox 
---
 .../pci/atomisp2/css2400/ia_css_mmu_private.h  |2 --
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   24 +---
 .../atomisp/pci/atomisp2/css2400/sh_css_mmu.c  |6 -
 3 files changed, 1 insertion(+), 31 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_mmu_private.h 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_mmu_private.h
index 7c85009..1021e4f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_mmu_private.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_mmu_private.h
@@ -1,4 +1,3 @@
-#ifdef ISP2401
 /*
  * Support for Intel Camera Imaging ISP subsystem.
  * Copyright (c) 2015, Intel Corporation.
@@ -28,4 +27,3 @@ void
 sh_css_mmu_set_page_table_base_index(hrt_data base_index);
 
 #endif /* __IA_CSS_MMU_PRIVATE_H */
-#endif
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index dfef219..471f2be 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -64,7 +64,7 @@
 #include "input_system.h"
 #endif
 #include "mmu_device.h"/* mmu_set_page_table_base_index(), ... 
*/
-//#include "ia_css_mmu_private.h" /* sh_css_mmu_set_page_table_base_index() */
+#include "ia_css_mmu_private.h" /* sh_css_mmu_set_page_table_base_index() */
 #include "gdc_device.h"/* HRT_GDC_N */
 #include "dma.h"   /* dma_set_max_burst_size() */
 #include "irq.h"   /* virq */
@@ -242,11 +242,6 @@ ia_css_reset_defaults(struct sh_css* css);
 static void
 sh_css_init_host_sp_control_vars(void);
 
-#ifndef ISP2401
-static void
-sh_css_mmu_set_page_table_base_index(hrt_data base_index);
-
-#endif
 static enum ia_css_err set_num_primary_stages(unsigned int *num, enum 
ia_css_pipe_version version);
 
 static bool
@@ -2595,23 +2590,6 @@ ia_css_uninit(void)
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_uninit() leave: 
return_void\n");
 }
 
-#ifndef ISP2401
-/* Deprecated, this is an HRT backend function (memory_access.h) */
-static void
-sh_css_mmu_set_page_table_base_index(hrt_data base_index)
-{
-   int i;
-   ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, 
"sh_css_mmu_set_page_table_base_index() enter: base_index=0x%08x\n",base_index);
-   my_css.page_table_base_index = base_index;
-   for (i = 0; i < (int)N_MMU_ID; i++) {
-   mmu_ID_t mmu_id = (mmu_ID_t)i;
-   mmu_set_page_table_base_index(mmu_id, base_index);
-   mmu_invalidate_cache(mmu_id);
-   }
-   ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, 
"sh_css_mmu_set_page_table_base_index() leave: return_void\n");
-}
-
-#endif
 #if defined(HAS_IRQ_MAP_VERSION_2)
 enum ia_css_err ia_css_irq_translate(
unsigned int *irq_infos)
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_mmu.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_mmu.c
index 6de8472..237e38b 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_mmu.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_mmu.c
@@ -13,16 +13,12 @@
  */
 
 #include "ia_css_mmu.h"
-#ifdef ISP2401
 #include "ia_css_mmu_private.h"
-#endif
 #include 
 #include "sh_css_sp.h"
 #include "sh_css_firmware.h"
 #include "sp.h"
-#ifdef ISP2401
 #include "mmu_device.h"
-#endif
 
 void
 ia_css_mmu_invalidate_cache(void)
@@ -44,7 +40,6 @@ ia_css_mmu_invalidate_cache(void)
}
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_mmu_invalidate_cache() 
leave\n");
 }
-#ifdef ISP2401
 
 /* Deprecated, this is an HRT backend function (memory_access.h) */
 void
@@ -59,4 +54,3 @@ sh_css_mmu_set_page_table_base_index(hrt_data base_index)
}
IA_CSS_LEAVE_PRIVATE("");
 }
-#endif



[PATCH 09/11] atomisp: Unify lut free logic

2017-05-26 Thread Alan Cox
ISP2401 introduced a helper for this which we can use just as well on the
ISP2400 and remove some more noise differences.

Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|7 ---
 .../atomisp/pci/atomisp2/css2400/sh_css_params.c   |   14 --
 2 files changed, 21 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 55d2a69..dfef219 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -2533,15 +2533,8 @@ ia_css_pipe_destroy(struct ia_css_pipe *pipe)
break;
}
 
-#ifndef ISP2401
-   if (pipe->scaler_pp_lut != mmgr_NULL) {
-   hmm_free(pipe->scaler_pp_lut);
-   pipe->scaler_pp_lut = mmgr_NULL;
-   }
-#else
sh_css_params_free_gdc_lut(pipe->scaler_pp_lut);
pipe->scaler_pp_lut = mmgr_NULL;
-#endif
 
my_css.active_pipes[ia_css_pipe_get_pipe_num(pipe)] = NULL;
sh_css_pipe_free_shading_table(pipe);
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c
index d8c22e8..4822437 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c
@@ -3356,15 +3356,8 @@ enum ia_css_err ia_css_pipe_set_bci_scaler_lut(struct 
ia_css_pipe *pipe,
}
 
/* Free any existing tables. */
-#ifndef ISP2401
-   if (pipe->scaler_pp_lut != mmgr_NULL) {
-   hmm_free(pipe->scaler_pp_lut);
-   pipe->scaler_pp_lut = mmgr_NULL;
-   }
-#else
sh_css_params_free_gdc_lut(pipe->scaler_pp_lut);
pipe->scaler_pp_lut = mmgr_NULL;
-#endif
 
 #ifndef ISP2401
if (store) {
@@ -3445,15 +3438,8 @@ void sh_css_params_free_default_gdc_lut(void)
 {
IA_CSS_ENTER_PRIVATE("void");
 
-#ifndef ISP2401
-   if (default_gdc_lut != mmgr_NULL) {
-   hmm_free(default_gdc_lut);
-   default_gdc_lut = mmgr_NULL;
-   }
-#else
sh_css_params_free_gdc_lut(default_gdc_lut);
default_gdc_lut = mmgr_NULL;
-#endif
 
IA_CSS_LEAVE_PRIVATE("void");
 



[PATCH 08/11] atomisp: Unify load_preview_binaries for the most part

2017-05-26 Thread Alan Cox
ISP2401 introduced a rather sensible change to cut through the structure
spaghetti. Adopt that for the ISP2400 as well. It makes no difference to the
actual code other than readability.

Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   40 +---
 1 file changed, 1 insertion(+), 39 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 8e1cd12..55d2a69 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -2923,11 +2923,8 @@ load_preview_binaries(struct ia_css_pipe *pipe)
 #endif
/* preview only have 1 output pin now */
struct ia_css_frame_info *pipe_out_info = >output_info[0];
-#ifdef ISP2401
struct ia_css_preview_settings *mycs  = >pipe_settings.preview;
 
-#endif
-
IA_CSS_ENTER_PRIVATE("");
assert(pipe != NULL);
assert(pipe->stream != NULL);
@@ -2939,11 +2936,7 @@ load_preview_binaries(struct ia_css_pipe *pipe)
sensor = pipe->stream->config.mode == IA_CSS_INPUT_MODE_SENSOR;
 #endif
 
-#ifndef ISP2401
-   if (pipe->pipe_settings.preview.preview_binary.info)
-#else
if (mycs->preview_binary.info)
-#endif
return IA_CSS_SUCCESS;
 
err = ia_css_util_check_input(>stream->config, false, false);
@@ -2996,12 +2989,7 @@ load_preview_binaries(struct ia_css_pipe *pipe)
_vf_info);
if (err != IA_CSS_SUCCESS)
return err;
-   err = ia_css_binary_find(_descr,
-#ifndef ISP2401
->pipe_settings.preview.preview_binary);
-#else
->preview_binary);
-#endif
+   err = ia_css_binary_find(_descr, >preview_binary);
if (err != IA_CSS_SUCCESS)
return err;
 
@@ -3017,24 +3005,15 @@ load_preview_binaries(struct ia_css_pipe *pipe)
 
 #endif
/* The vf_pp binary is needed when (further) YUV downscaling is 
required */
-#ifndef ISP2401
-   need_vf_pp |= 
pipe->pipe_settings.preview.preview_binary.out_frame_info[0].res.width != 
pipe_out_info->res.width;
-   need_vf_pp |= 
pipe->pipe_settings.preview.preview_binary.out_frame_info[0].res.height != 
pipe_out_info->res.height;
-#else
need_vf_pp |= mycs->preview_binary.out_frame_info[0].res.width != 
pipe_out_info->res.width;
need_vf_pp |= mycs->preview_binary.out_frame_info[0].res.height != 
pipe_out_info->res.height;
-#endif
 
/* When vf_pp is needed, then the output format of the selected
 * preview binary must be yuv_line. If this is not the case,
 * then the preview binary selection is done again.
 */
if (need_vf_pp &&
-#ifndef ISP2401
-   
(pipe->pipe_settings.preview.preview_binary.out_frame_info[0].format != 
IA_CSS_FRAME_FORMAT_YUV_LINE)) {
-#else
(mycs->preview_binary.out_frame_info[0].format != 
IA_CSS_FRAME_FORMAT_YUV_LINE)) {
-#endif
 
/* Preview step 2 */
if (pipe->vf_yuv_ds_input_info.res.width)
@@ -3055,11 +3034,7 @@ load_preview_binaries(struct ia_css_pipe *pipe)
if (err != IA_CSS_SUCCESS)
return err;
err = ia_css_binary_find(_descr,
-#ifndef ISP2401
-   >pipe_settings.preview.preview_binary);
-#else
>preview_binary);
-#endif
if (err != IA_CSS_SUCCESS)
return err;
}
@@ -3069,18 +3044,10 @@ load_preview_binaries(struct ia_css_pipe *pipe)
 
/* Viewfinder post-processing */
ia_css_pipe_get_vfpp_binarydesc(pipe, _pp_descr,
-#ifndef ISP2401
-   
>pipe_settings.preview.preview_binary.out_frame_info[0],
-#else
>preview_binary.out_frame_info[0],
-#endif
pipe_out_info);
err = ia_css_binary_find(_pp_descr,
-#ifndef ISP2401
->pipe_settings.preview.vf_pp_binary);
-#else
 >vf_pp_binary);
-#endif
if (err != IA_CSS_SUCCESS)
return err;
}
@@ -3106,13 +3073,8 @@ load_preview_binaries(struct ia_css_pipe *pipe)
/* Copy */
if (need_isp_copy_binary) {
err = load_copy_binary(pipe,
-#ifndef ISP2401
-  >pipe_settings.preview.copy_binary,
-  
>pipe_settings.preview.preview_binary);
-#else
   >copy_binary,
   >preview_binary);
-#endif
if (err != IA_CSS_SUCCESS)
return err;
}



[PATCH 07/11] atomisp: unify sh_css_hmm_buffer_record_acquire

2017-05-26 Thread Alan Cox
The ISP2401 version of this function returns a pointer to the buffer, whilst
the ISP2400 version returns a boolean if a slot is found. We can trivially
unify the code to use the ISP2401 version.

Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   40 ++--
 1 file changed, 3 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 4f3a2ea..8e1cd12 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -375,13 +375,8 @@ sh_css_hmm_buffer_record_uninit(void);
 static void
 sh_css_hmm_buffer_record_reset(struct sh_css_hmm_buffer_record *buffer_record);
 
-#ifndef ISP2401
-static bool
-sh_css_hmm_buffer_record_acquire(struct ia_css_rmgr_vbuf_handle *h_vbuf,
-#else
 static struct sh_css_hmm_buffer_record
 *sh_css_hmm_buffer_record_acquire(struct ia_css_rmgr_vbuf_handle *h_vbuf,
-#endif
enum ia_css_buffer_type type,
hrt_address kernel_ptr);
 
@@ -4423,21 +4418,9 @@ ia_css_pipe_enqueue_buffer(struct ia_css_pipe *pipe,
}
 
if (return_err == IA_CSS_SUCCESS) {
-#ifndef ISP2401
-   bool found_record = false;
-   found_record = sh_css_hmm_buffer_record_acquire(
-#else
-   struct sh_css_hmm_buffer_record *hmm_buffer_record = NULL;
-
-   hmm_buffer_record = sh_css_hmm_buffer_record_acquire(
-#endif
-   h_vbuf, buf_type,
-   HOST_ADDRESS(ddr_buffer.kernel_ptr));
-#ifndef ISP2401
-   if (found_record == true) {
-#else
-   if (hmm_buffer_record) {
-#endif
+   if (sh_css_hmm_buffer_record_acquire(
+   h_vbuf, buf_type,
+   HOST_ADDRESS(ddr_buffer.kernel_ptr))) {
IA_CSS_LOG("send vbuf=%p", h_vbuf);
} else {
return_err = IA_CSS_ERR_INTERNAL_ERROR;
@@ -11139,23 +11122,14 @@ sh_css_hmm_buffer_record_reset(struct 
sh_css_hmm_buffer_record *buffer_record)
buffer_record->kernel_ptr = 0;
 }
 
-#ifndef ISP2401
-static bool
-sh_css_hmm_buffer_record_acquire(struct ia_css_rmgr_vbuf_handle *h_vbuf,
-#else
 static struct sh_css_hmm_buffer_record
 *sh_css_hmm_buffer_record_acquire(struct ia_css_rmgr_vbuf_handle *h_vbuf,
-#endif
enum ia_css_buffer_type type,
hrt_address kernel_ptr)
 {
int i;
struct sh_css_hmm_buffer_record *buffer_record = NULL;
-#ifndef ISP2401
-   bool found_record = false;
-#else
struct sh_css_hmm_buffer_record *out_buffer_record = NULL;
-#endif
 
assert(h_vbuf != NULL);
assert((type > IA_CSS_BUFFER_TYPE_INVALID) && (type < 
IA_CSS_NUM_DYNAMIC_BUFFER_TYPE));
@@ -11168,21 +11142,13 @@ static struct sh_css_hmm_buffer_record
buffer_record->type = type;
buffer_record->h_vbuf = h_vbuf;
buffer_record->kernel_ptr = kernel_ptr;
-#ifndef ISP2401
-   found_record = true;
-#else
out_buffer_record = buffer_record;
-#endif
break;
}
buffer_record++;
}
 
-#ifndef ISP2401
-   return found_record;
-#else
return out_buffer_record;
-#endif
 }
 
 static struct sh_css_hmm_buffer_record



[PATCHv2 06/11] atomisp: eliminate dead code under HAS_RES_MGR

2017-05-26 Thread Alan Cox
This define is never set and these code paths are never used so they can go
away.

Signed-off-by: Alan Cox 
---
 .../css2400/isp/modes/interface/isp_const.h|   16 -
 .../css2400/isp/modes/interface/isp_exprs.h|   23 --
 .../atomisp2/css2400/runtime/binary/src/binary.c   |   34 
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   30 --
 4 files changed, 103 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/modes/interface/isp_const.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/modes/interface/isp_const.h
index 005eaaa..2f215dc 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/modes/interface/isp_const.h
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/modes/interface/isp_const.h
@@ -398,17 +398,6 @@ more details.
  * so the calc for the output buffer vmem size is:
  * ((width[vectors]/num_of_stripes) + 2[vectors])
  */
-#if defined(HAS_RES_MGR)
-#define MAX_VECTORS_PER_OUTPUT_LINE \
-   (CEIL_DIV(CEIL_DIV(ISP_MAX_OUTPUT_WIDTH, ISP_NUM_STRIPES) + 
ISP_LEFT_PADDING, ISP_VEC_NELEMS) + \
-   ITERATOR_VECTOR_INCREMENT)
-
-#define MAX_VECTORS_PER_INPUT_LINE CEIL_DIV(ISP_MAX_INPUT_WIDTH, 
ISP_VEC_NELEMS)
-#define MAX_VECTORS_PER_INPUT_STRIPE   
(CEIL_ROUND_DIV_STRIPE(CEIL_DIV(ISP_MAX_INPUT_WIDTH, ISP_VEC_NELEMS) , \
- ISP_NUM_STRIPES, \
- 
ISP_LEFT_PADDING_VECS) + \
- 
ITERATOR_VECTOR_INCREMENT)
-#else /* !defined(HAS_RES_MGR)*/
 #define MAX_VECTORS_PER_OUTPUT_LINE \
CEIL_DIV(CEIL_DIV(ISP_MAX_OUTPUT_WIDTH, ISP_NUM_STRIPES) + 
ISP_LEFT_PADDING, ISP_VEC_NELEMS)
 
@@ -417,7 +406,6 @@ more details.
 #define MAX_VECTORS_PER_INPUT_STRIPE   
CEIL_ROUND_DIV_STRIPE(MAX_VECTORS_PER_INPUT_LINE, \
  ISP_NUM_STRIPES, \
  
ISP_LEFT_PADDING_VECS)
-#endif /* HAS_RES_MGR */
 
 
 /* Add 2 for left croppping */
@@ -470,15 +458,11 @@ more details.
 
 #define RAW_BUF_LINES ((ENABLE_RAW_BINNING || ENABLE_FIXED_BAYER_DS) ? 4 : 2)
 
-#if defined(HAS_RES_MGR)
-#define RAW_BUF_STRIDE (MAX_VECTORS_PER_INPUT_STRIPE)
-#else /* !defined(HAS_RES_MGR) */
 #define RAW_BUF_STRIDE \
(BINARY_ID == SH_CSS_BINARY_ID_POST_ISP ? MAX_VECTORS_PER_INPUT_CHUNK : 
\
 ISP_NUM_STRIPES > 1 ? 
MAX_VECTORS_PER_INPUT_STRIPE+_ISP_EXTRA_PADDING_VECS : \
 !ENABLE_CONTINUOUS ? MAX_VECTORS_PER_INPUT_LINE : \
 MAX_VECTORS_PER_INPUT_CHUNK)
-#endif /* HAS_RES_MGR */
 
 /* [isp vmem] table size[vectors] per line per color (GR,R,B,GB),
multiples of NWAY */
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/modes/interface/isp_exprs.h
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/modes/interface/isp_exprs.h
index 8b59a8c..e625ba6 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/modes/interface/isp_exprs.h
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/modes/interface/isp_exprs.h
@@ -214,24 +214,6 @@ more details.
 /*** STRIPING-RELATED MACROS ***/
 #define NO_STRIPING (ISP_NUM_STRIPES == 1)
 
-#if defined(HAS_RES_MGR)
-
-#define ISP_OUTPUT_CHUNK_VECS ISP_INTERNAL_WIDTH_VECS
-
-#if defined(__ISP)
-#define VECTORS_PER_LINE ISP_INTERNAL_WIDTH_VECS
-#else
-#define VECTORS_PER_LINE \
-   (NO_STRIPING? ISP_INTERNAL_WIDTH_VECS \
-   : 
ISP_IO_STRIPE_WIDTH_VECS(ISP_INTERNAL_WIDTH_VECS, ISP_LEFT_PADDING_VECS, 
ISP_NUM_STRIPES, ISP_MIN_STRIPE_WIDTH) )
-#endif
-
-#define VECTORS_PER_INPUT_LINE \
-   (NO_STRIPING? ISP_INPUT_WIDTH_VECS \
-   : 
ISP_IO_STRIPE_WIDTH_VECS(ISP_INPUT_WIDTH_VECS, ISP_LEFT_PADDING_VECS, 
ISP_NUM_STRIPES, ISP_MIN_STRIPE_WIDTH) )
-
-#else
-
 #define ISP_OUTPUT_CHUNK_VECS \
(NO_STRIPING? CEIL_DIV_CHUNKS(ISP_OUTPUT_VECS_EXTRA_CROP, 
OUTPUT_NUM_CHUNKS) \
: 
ISP_IO_STRIPE_WIDTH_VECS(ISP_OUTPUT_VECS_EXTRA_CROP, ISP_LEFT_PADDING_VECS, 
ISP_NUM_STRIPES, ISP_MIN_STRIPE_WIDTH) )
@@ -244,7 +226,6 @@ more details.
(NO_STRIPING? ISP_INPUT_WIDTH_VECS \
: 
ISP_IO_STRIPE_WIDTH_VECS(ISP_INPUT_WIDTH_VECS, ISP_LEFT_PADDING_VECS, 
ISP_NUM_STRIPES, ISP_MIN_STRIPE_WIDTH)+_ISP_EXTRA_PADDING_VECS)
 
-#endif
 
 #define ISP_MAX_VF_OUTPUT_STRIPE_VECS \
(NO_STRIPING? ISP_MAX_VF_OUTPUT_VECS \
@@ -282,11 +263,7 @@ more details.
 #define OUTPUT_VECTORS_PER_CHUNK   
CEIL_DIV_CHUNKS(VECTORS_PER_LINE,OUTPUT_NUM_CHUNKS)
 
 /* should be even?? */
-#if !defined(HAS_RES_MGR)
 #define OUTPUT_C_VECTORS_PER_CHUNK CEIL_DIV(OUTPUT_VECTORS_PER_CHUNK, 2)
-#else
-#define OUTPUT_C_VECTORS_PER_CHUNK CEIL_DIV(MAX_VECTORS_PER_CHUNK, 

[PATCHv2 04/11] atomisp2: tidy up confused ifdefs

2017-05-26 Thread Alan Cox
The two drivers were machine merged and in this case the machine output was to
say the least not optimal.

Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   26 
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 231c3f8..8d44608 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -1469,30 +1469,17 @@ static void start_pipe(
copy_ovrd,
input_mode,
>stream->config.metadata_config,
-#ifndef ISP2401
>stream->info.metadata_info
-#else
-   >stream->info.metadata_info,
-#endif
 #if !defined(HAS_NO_INPUT_SYSTEM)
-#ifndef ISP2401
-   , (input_mode==IA_CSS_INPUT_MODE_MEMORY)?
-#else
-   (input_mode == IA_CSS_INPUT_MODE_MEMORY) ?
-#endif
+   ,(input_mode==IA_CSS_INPUT_MODE_MEMORY) ?
(mipi_port_ID_t)0 :
-#ifndef ISP2401
me->stream->config.source.port.port
-#else
-   me->stream->config.source.port.port,
 #endif
+#ifdef ISP2401
+   ,>config.internal_frame_origin_bqs_on_sctbl,
+   me->stream->isp_params_configs
 #endif
-#ifndef ISP2401
-   );
-#else
-   >config.internal_frame_origin_bqs_on_sctbl,
-   me->stream->isp_params_configs);
-#endif
+   );
 
if (me->config.mode != IA_CSS_PIPE_MODE_COPY) {
struct ia_css_pipeline_stage *stage;
@@ -9815,9 +9802,6 @@ ia_css_stream_create(const struct ia_css_stream_config 
*stream_config,
/* take over effective info */
 
effective_res = curr_pipe->config.input_effective_res;
-#endif
-
-#ifndef ISP2401
err = ia_css_util_check_res(
effective_res.width,
effective_res.height);



[PATCH 05/11] atomisp2: off by one in atomisp_s_input()

2017-05-26 Thread Alan Cox
From: Dan Carpenter 

The isp->inputs[] array has isp->input_cnt elements which have been
initialized so this > should be >=.

This bug is harmless.  The check against ATOM_ISP_MAX_INPUTS prevents us
from reading beyond the end of the array.  The uninitialized elements
are zeroed out so we will end up returning -EINVAL a few lines later
because the .camera pointer is NULL.

Signed-off-by: Dan Carpenter 
Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/atomisp_ioctl.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c
index 6064bb8..aa0526e 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c
@@ -683,7 +683,7 @@ static int atomisp_s_input(struct file *file, void *fh, 
unsigned int input)
int ret;
 
rt_mutex_lock(>mutex);
-   if (input >= ATOM_ISP_MAX_INPUTS || input > isp->input_cnt) {
+   if (input >= ATOM_ISP_MAX_INPUTS || input >= isp->input_cnt) {
dev_dbg(isp->dev, "input_cnt: %d\n", isp->input_cnt);
ret = -EINVAL;
goto error;



[PATCHv2 03/11] atomisp2: remove HRT_UNSCHED

2017-05-26 Thread Alan Cox
HRT_UNSCHED is never defined or set in the driver, so this is dead code that
can be retired, simplifying the code a bit further.

Signed-off-by: Alan Cox 
---
 .../css2400/runtime/debug/src/ia_css_debug.c   |7 ---
 .../atomisp2/css2400/runtime/spctrl/src/spctrl.c   |8 +---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   10 ++
 .../atomisp/pci/atomisp2/css2400/sh_css_firmware.c |5 -
 4 files changed, 3 insertions(+), 27 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
index bcc0d46..0fa7cb2 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
@@ -176,7 +176,6 @@ void ia_css_debug_dtrace(unsigned int level, const char 
*fmt, ...)
va_end(ap);
 }
 
-#if !defined(HRT_UNSCHED)
 static void debug_dump_long_array_formatted(
const sp_ID_t sp_id,
hrt_address stack_sp_addr,
@@ -249,12 +248,6 @@ void ia_css_debug_dump_sp_stack_info(void)
 {
debug_dump_sp_stack_info(SP0_ID);
 }
-#else
-/* Empty def for crun */
-void ia_css_debug_dump_sp_stack_info(void)
-{
-}
-#endif /* #if !HRT_UNSCHED */
 
 
 void ia_css_debug_set_dtrace_level(const unsigned int trace_level)
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
index b36d7b0..b3a28ba 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
@@ -62,12 +62,6 @@ enum ia_css_err ia_css_spctrl_load_fw(sp_ID_t sp_id,
 
spctrl_cofig_info[sp_id].code_addr = mmgr_NULL;
 
-#if defined(HRT_UNSCHED)
-   (void)init_dmem_cfg;
-   code_addr = mmgr_malloc(1);
-   if (code_addr == mmgr_NULL)
-   return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
-#else
init_dmem_cfg = _cofig_info[sp_id].dmem_config;
init_dmem_cfg->dmem_data_addr = spctrl_cfg->dmem_data_addr;
init_dmem_cfg->dmem_bss_addr  = spctrl_cfg->dmem_bss_addr;
@@ -104,7 +98,7 @@ enum ia_css_err ia_css_spctrl_load_fw(sp_ID_t sp_id,
code_addr = mmgr_NULL;
return IA_CSS_ERR_INTERNAL_ERROR;
}
-#endif
+
spctrl_cofig_info[sp_id].sp_entry = spctrl_cfg->sp_entry;
spctrl_cofig_info[sp_id].code_addr = code_addr;
spctrl_cofig_info[sp_id].program_name = spctrl_cfg->program_name;
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 19dc843..231c3f8 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -1575,7 +1575,6 @@ static bool sh_css_setup_spctrl_config(const struct 
ia_css_fw_info *fw,
spctrl_cfg->sp_entry = 0;
spctrl_cfg->program_name = (char *)(program);
 
-#if !defined(HRT_UNSCHED)
spctrl_cfg->ddr_data_offset =  fw->blob.data_source;
spctrl_cfg->dmem_data_addr = fw->blob.data_target;
spctrl_cfg->dmem_bss_addr = fw->blob.bss_target;
@@ -1588,7 +1587,7 @@ static bool sh_css_setup_spctrl_config(const struct 
ia_css_fw_info *fw,
spctrl_cfg->code_size = fw->blob.size;
spctrl_cfg->code  = fw->blob.code;
spctrl_cfg->sp_entry  = fw->info.sp.sp_entry; /* entry function ptr on 
SP */
-#endif
+
return true;
 }
 void
@@ -8570,9 +8569,7 @@ remove_firmware(struct ia_css_fw_info **l, struct 
ia_css_fw_info *firmware)
return; /* removing single and multiple firmware is handled in 
acc_unload_extension() */
 }
 
-#if !defined(HRT_UNSCHED)
-static enum ia_css_err
-upload_isp_code(struct ia_css_fw_info *firmware)
+static enum ia_css_err upload_isp_code(struct ia_css_fw_info *firmware)
 {
hrt_vaddress binary;
 
@@ -8600,12 +8597,10 @@ upload_isp_code(struct ia_css_fw_info *firmware)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
return IA_CSS_SUCCESS;
 }
-#endif
 
 static enum ia_css_err
 acc_load_extension(struct ia_css_fw_info *firmware)
 {
-#if !defined(HRT_UNSCHED)
enum ia_css_err err;
struct ia_css_fw_info *hd = firmware;
while (hd){
@@ -8614,7 +8609,6 @@ acc_load_extension(struct ia_css_fw_info *firmware)
return err;
hd = hd->next;
}
-#endif
 
if (firmware == NULL)
return IA_CSS_ERR_INVALID_ARGUMENTS;
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index a179de5..eecd8cf 100644
--- 

[PATCHv2 02/11] atomisp: remove NUM_OF_BLS

2017-05-26 Thread Alan Cox
With the removal of the HAS_BL bootloader code the value of NUM_OF_BLS is an
invariant zero. So let's get rid of it.

Signed-off-by: Alan Cox 
---
 .../atomisp/pci/atomisp2/css2400/sh_css_firmware.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 57b4fe5..a179de5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -234,9 +234,9 @@ sh_css_load_firmware(const char *fw_data,
 
sh_css_num_binaries = file_header->binary_nr;
/* Only allocate memory for ISP blob info */
-   if (sh_css_num_binaries > (NUM_OF_SPS + NUM_OF_BLS)) {
+   if (sh_css_num_binaries > NUM_OF_SPS) {
sh_css_blob_info = kmalloc(
-   (sh_css_num_binaries - (NUM_OF_SPS + 
NUM_OF_BLS)) *
+   (sh_css_num_binaries - NUM_OF_SPS) *
sizeof(*sh_css_blob_info), GFP_KERNEL);
if (sh_css_blob_info == NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
@@ -272,15 +272,15 @@ sh_css_load_firmware(const char *fw_data,
if (err != IA_CSS_SUCCESS)
return err;
} else {
-   /* All subsequent binaries (including bootloaders) 
(i>NUM_OF_SPS+NUM_OF_BLS) are ISP firmware */
-   if (i < (NUM_OF_SPS + NUM_OF_BLS))
+   /* All subsequent binaries (including bootloaders) 
(i>NUM_OF_SPS) are ISP firmware */
+   if (i < NUM_OF_SPS)
return IA_CSS_ERR_INTERNAL_ERROR;
 
if (bi->type != ia_css_isp_firmware)
return IA_CSS_ERR_INTERNAL_ERROR;
if (sh_css_blob_info == NULL) /* cannot happen but KW 
does not see this */
return IA_CSS_ERR_INTERNAL_ERROR;
-   sh_css_blob_info[i-(NUM_OF_SPS + NUM_OF_BLS)] = bd;
+   sh_css_blob_info[i - NUM_OF_SPS] = bd;
}
}
 



[PATCHv2 01/11] atompisp: HAS_BL is never defined so lose it

2017-05-26 Thread Alan Cox
Kill off the HAS_BL define and the code and includes it brackets. We never
define HAS_BL or use that functionality.

Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|  101 
 .../atomisp/pci/atomisp2/css2400/sh_css_firmware.c |   19 
 .../atomisp/pci/atomisp2/css2400/sh_css_internal.h |7 -
 3 files changed, 1 insertion(+), 126 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 81a21a0..19dc843 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -98,18 +98,12 @@ static int thread_alive;
 
 #include "isp/modes/interface/input_buf.isp.h"
 
-#if defined(HAS_BL)
-#include "support/bootloader/interface/ia_css_blctrl.h"
-#endif
 #if defined(HAS_RES_MGR)
 #include "components/acc_cluster/gen/host/acc_cluster.host.h"
 #endif
 
 /* Name of the sp program: should not be built-in */
 #define SP_PROG_NAME "sp"
-#if defined(HAS_BL)
-#define BL_PROG_NAME "bootloader"
-#endif
 /* Size of Refcount List */
 #define REFCOUNT_SIZE 1000
 
@@ -1571,34 +1565,7 @@ enable_interrupts(enum ia_css_irq_type irq_type)
 }
 
 #endif
-#if defined(HAS_BL)
-static bool sh_css_setup_blctrl_config(const struct ia_css_fw_info *fw,
-   const char *program,
-   ia_css_blctrl_cfg  
*blctrl_cfg)
-{
-   if((fw == NULL)||(blctrl_cfg == NULL))
-   return false;
-   blctrl_cfg->bl_entry = 0;
-   blctrl_cfg->program_name = (char *)(program);
-
-#if !defined(HRT_UNSCHED)
-   blctrl_cfg->ddr_data_offset =  fw->blob.data_source;
-   blctrl_cfg->dmem_data_addr = fw->blob.data_target;
-   blctrl_cfg->dmem_bss_addr = fw->blob.bss_target;
-   blctrl_cfg->data_size = fw->blob.data_size ;
-   blctrl_cfg->bss_size = fw->blob.bss_size;
-
-   blctrl_cfg->blctrl_state_dmem_addr = fw->info.bl.sw_state;
-   blctrl_cfg->blctrl_dma_cmd_list = fw->info.bl.dma_cmd_list;
-   blctrl_cfg->blctrl_nr_of_dma_cmds = fw->info.bl.num_dma_cmds;
 
-   blctrl_cfg->code_size = fw->blob.size;
-   blctrl_cfg->code  = fw->blob.code;
-   blctrl_cfg->bl_entry  = fw->info.bl.bl_entry; /* entry function ptr on 
Bootloader */
-#endif
-   return true;
-}
-#endif
 static bool sh_css_setup_spctrl_config(const struct ia_css_fw_info *fw,
const char * program,
ia_css_spctrl_cfg  
*spctrl_cfg)
@@ -1708,9 +1675,6 @@ ia_css_init(const struct ia_css_env *env,
 {
enum ia_css_err err;
ia_css_spctrl_cfg spctrl_cfg;
-#if defined(HAS_BL)
-   ia_css_blctrl_cfg blctrl_cfg;
-#endif
 
void (*flush_func)(struct ia_css_acc_fw *fw);
hrt_data select, enable;
@@ -1863,26 +1827,6 @@ ia_css_init(const struct ia_css_env *env,
return err;
}
 
-#if defined(HAS_BL)
-   if (!sh_css_setup_blctrl_config(_css_bl_fw, BL_PROG_NAME, 
_cfg))
-   return IA_CSS_ERR_INTERNAL_ERROR;
-   err = ia_css_blctrl_load_fw(_cfg);
-   if (err != IA_CSS_SUCCESS) {
-   IA_CSS_LEAVE_ERR(err);
-   return err;
-   }
-
-#ifdef ISP2401
-   err = ia_css_blctrl_add_target_fw_info(_css_sp_fw, IA_CSS_SP0,
-get_sp_code_addr(SP0_ID));
-
-#endif
-   if (err != IA_CSS_SUCCESS) {
-   IA_CSS_LEAVE_ERR(err);
-   return err;
-   }
-#endif /* HAS_BL */
-
 #if WITH_PC_MONITORING
if (!thread_alive) {
thread_alive++;
@@ -2667,9 +2611,6 @@ ia_css_uninit(void)
}
ia_css_spctrl_unload_fw(SP0_ID);
sh_css_sp_set_sp_running(false);
-#if defined(HAS_BL)
-   ia_css_blctrl_unload_fw();
-#endif
 #if defined(USE_INPUT_SYSTEM_VERSION_2) || 
defined(USE_INPUT_SYSTEM_VERSION_2401)
/* check and free any remaining mipi frames */
free_mipi_frames(NULL);
@@ -10588,39 +10529,6 @@ ia_css_pipe_get_isp_pipe_version(const struct 
ia_css_pipe *pipe)
return (unsigned int)pipe->config.isp_pipe_version;
 }
 
-#if defined(HAS_BL)
-#define BL_START_TIMEOUT_US 3000
-static enum ia_css_err
-ia_css_start_bl(void)
-{
-   enum ia_css_err err = IA_CSS_SUCCESS;
-   unsigned long timeout;
-
-   IA_CSS_ENTER("");
-   sh_css_start_bl();
-   /* waiting for the Bootloader to complete execution */
-   timeout = BL_START_TIMEOUT_US;
-   while((ia_css_blctrl_get_state() == BOOTLOADER_BUSY) && timeout) {
-   timeout--;
-   hrt_sleep();
-   }
-   ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-   "Bootloader state %d\n", ia_css_blctrl_get_state());
-   if (timeout == 0) {
-   

[PATCH 05/12] hdlcdrv: Fix division by zero when bitrate is unset

2017-05-26 Thread Alan Cox
The code attempts to check for out of range calibration. What it forgets to do
is check for the 0 bitrate case. As a result the range check itself oopses the
kernel.

Found by Andrey Konovalov using Syzkaller.

Signed-off-by: Alan Cox 
---
 drivers/net/hamradio/hdlcdrv.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 8c3633c..9f34a48 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -576,7 +576,7 @@ static int hdlcdrv_ioctl(struct net_device *dev, struct 
ifreq *ifr, int cmd)
case HDLCDRVCTL_CALIBRATE:
if(!capable(CAP_SYS_RAWIO))
return -EPERM;
-   if (bi.data.calibrate > INT_MAX / s->par.bitrate)
+   if (!s->par.bitrate || bi.data.calibrate > INT_MAX / 
s->par.bitrate)
return -EINVAL;
s->hdlctx.calibrate = bi.data.calibrate * s->par.bitrate / 16;
return 0;



[PATCH 04/12] atomisp2: tidy up confused ifdefs

2017-05-26 Thread Alan Cox
The two drivers were machine merged and in this case the machine output was to
say the least not optimal.

Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   26 
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 231c3f8..8d44608 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -1469,30 +1469,17 @@ static void start_pipe(
copy_ovrd,
input_mode,
>stream->config.metadata_config,
-#ifndef ISP2401
>stream->info.metadata_info
-#else
-   >stream->info.metadata_info,
-#endif
 #if !defined(HAS_NO_INPUT_SYSTEM)
-#ifndef ISP2401
-   , (input_mode==IA_CSS_INPUT_MODE_MEMORY)?
-#else
-   (input_mode == IA_CSS_INPUT_MODE_MEMORY) ?
-#endif
+   ,(input_mode==IA_CSS_INPUT_MODE_MEMORY) ?
(mipi_port_ID_t)0 :
-#ifndef ISP2401
me->stream->config.source.port.port
-#else
-   me->stream->config.source.port.port,
 #endif
+#ifdef ISP2401
+   ,>config.internal_frame_origin_bqs_on_sctbl,
+   me->stream->isp_params_configs
 #endif
-#ifndef ISP2401
-   );
-#else
-   >config.internal_frame_origin_bqs_on_sctbl,
-   me->stream->isp_params_configs);
-#endif
+   );
 
if (me->config.mode != IA_CSS_PIPE_MODE_COPY) {
struct ia_css_pipeline_stage *stage;
@@ -9815,9 +9802,6 @@ ia_css_stream_create(const struct ia_css_stream_config 
*stream_config,
/* take over effective info */
 
effective_res = curr_pipe->config.input_effective_res;
-#endif
-
-#ifndef ISP2401
err = ia_css_util_check_res(
effective_res.width,
effective_res.height);



[PATCH 03/12] atomisp2: remove HRT_UNSCHED

2017-05-26 Thread Alan Cox
HRT_UNSCHED is never defined or set in the driver, so this is dead code that
can be retired, simplifying the code a bit further.

Signed-off-by: Alan Cox 
---
 .../css2400/runtime/debug/src/ia_css_debug.c   |7 ---
 .../atomisp2/css2400/runtime/spctrl/src/spctrl.c   |8 +---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|   10 ++
 .../atomisp/pci/atomisp2/css2400/sh_css_firmware.c |5 -
 4 files changed, 3 insertions(+), 27 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
index bcc0d46..0fa7cb2 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/debug/src/ia_css_debug.c
@@ -176,7 +176,6 @@ void ia_css_debug_dtrace(unsigned int level, const char 
*fmt, ...)
va_end(ap);
 }
 
-#if !defined(HRT_UNSCHED)
 static void debug_dump_long_array_formatted(
const sp_ID_t sp_id,
hrt_address stack_sp_addr,
@@ -249,12 +248,6 @@ void ia_css_debug_dump_sp_stack_info(void)
 {
debug_dump_sp_stack_info(SP0_ID);
 }
-#else
-/* Empty def for crun */
-void ia_css_debug_dump_sp_stack_info(void)
-{
-}
-#endif /* #if !HRT_UNSCHED */
 
 
 void ia_css_debug_set_dtrace_level(const unsigned int trace_level)
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
index b36d7b0..b3a28ba 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
@@ -62,12 +62,6 @@ enum ia_css_err ia_css_spctrl_load_fw(sp_ID_t sp_id,
 
spctrl_cofig_info[sp_id].code_addr = mmgr_NULL;
 
-#if defined(HRT_UNSCHED)
-   (void)init_dmem_cfg;
-   code_addr = mmgr_malloc(1);
-   if (code_addr == mmgr_NULL)
-   return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
-#else
init_dmem_cfg = _cofig_info[sp_id].dmem_config;
init_dmem_cfg->dmem_data_addr = spctrl_cfg->dmem_data_addr;
init_dmem_cfg->dmem_bss_addr  = spctrl_cfg->dmem_bss_addr;
@@ -104,7 +98,7 @@ enum ia_css_err ia_css_spctrl_load_fw(sp_ID_t sp_id,
code_addr = mmgr_NULL;
return IA_CSS_ERR_INTERNAL_ERROR;
}
-#endif
+
spctrl_cofig_info[sp_id].sp_entry = spctrl_cfg->sp_entry;
spctrl_cofig_info[sp_id].code_addr = code_addr;
spctrl_cofig_info[sp_id].program_name = spctrl_cfg->program_name;
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 19dc843..231c3f8 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -1575,7 +1575,6 @@ static bool sh_css_setup_spctrl_config(const struct 
ia_css_fw_info *fw,
spctrl_cfg->sp_entry = 0;
spctrl_cfg->program_name = (char *)(program);
 
-#if !defined(HRT_UNSCHED)
spctrl_cfg->ddr_data_offset =  fw->blob.data_source;
spctrl_cfg->dmem_data_addr = fw->blob.data_target;
spctrl_cfg->dmem_bss_addr = fw->blob.bss_target;
@@ -1588,7 +1587,7 @@ static bool sh_css_setup_spctrl_config(const struct 
ia_css_fw_info *fw,
spctrl_cfg->code_size = fw->blob.size;
spctrl_cfg->code  = fw->blob.code;
spctrl_cfg->sp_entry  = fw->info.sp.sp_entry; /* entry function ptr on 
SP */
-#endif
+
return true;
 }
 void
@@ -8570,9 +8569,7 @@ remove_firmware(struct ia_css_fw_info **l, struct 
ia_css_fw_info *firmware)
return; /* removing single and multiple firmware is handled in 
acc_unload_extension() */
 }
 
-#if !defined(HRT_UNSCHED)
-static enum ia_css_err
-upload_isp_code(struct ia_css_fw_info *firmware)
+static enum ia_css_err upload_isp_code(struct ia_css_fw_info *firmware)
 {
hrt_vaddress binary;
 
@@ -8600,12 +8597,10 @@ upload_isp_code(struct ia_css_fw_info *firmware)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
return IA_CSS_SUCCESS;
 }
-#endif
 
 static enum ia_css_err
 acc_load_extension(struct ia_css_fw_info *firmware)
 {
-#if !defined(HRT_UNSCHED)
enum ia_css_err err;
struct ia_css_fw_info *hd = firmware;
while (hd){
@@ -8614,7 +8609,6 @@ acc_load_extension(struct ia_css_fw_info *firmware)
return err;
hd = hd->next;
}
-#endif
 
if (firmware == NULL)
return IA_CSS_ERR_INVALID_ARGUMENTS;
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index a179de5..eecd8cf 100644
--- 

[PATCH 02/12] atomisp: remove NUM_OF_BLS

2017-05-26 Thread Alan Cox
With the removal of the HAS_BL bootloader code the value of NUM_OF_BLS is an
invariant zero. So let's get rid of it.

Signed-off-by: Alan Cox 
---
 .../atomisp/pci/atomisp2/css2400/sh_css_firmware.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 57b4fe5..a179de5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -234,9 +234,9 @@ sh_css_load_firmware(const char *fw_data,
 
sh_css_num_binaries = file_header->binary_nr;
/* Only allocate memory for ISP blob info */
-   if (sh_css_num_binaries > (NUM_OF_SPS + NUM_OF_BLS)) {
+   if (sh_css_num_binaries > NUM_OF_SPS) {
sh_css_blob_info = kmalloc(
-   (sh_css_num_binaries - (NUM_OF_SPS + 
NUM_OF_BLS)) *
+   (sh_css_num_binaries - NUM_OF_SPS) *
sizeof(*sh_css_blob_info), GFP_KERNEL);
if (sh_css_blob_info == NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
@@ -272,15 +272,15 @@ sh_css_load_firmware(const char *fw_data,
if (err != IA_CSS_SUCCESS)
return err;
} else {
-   /* All subsequent binaries (including bootloaders) 
(i>NUM_OF_SPS+NUM_OF_BLS) are ISP firmware */
-   if (i < (NUM_OF_SPS + NUM_OF_BLS))
+   /* All subsequent binaries (including bootloaders) 
(i>NUM_OF_SPS) are ISP firmware */
+   if (i < NUM_OF_SPS)
return IA_CSS_ERR_INTERNAL_ERROR;
 
if (bi->type != ia_css_isp_firmware)
return IA_CSS_ERR_INTERNAL_ERROR;
if (sh_css_blob_info == NULL) /* cannot happen but KW 
does not see this */
return IA_CSS_ERR_INTERNAL_ERROR;
-   sh_css_blob_info[i-(NUM_OF_SPS + NUM_OF_BLS)] = bd;
+   sh_css_blob_info[i - NUM_OF_SPS] = bd;
}
}
 



[PATCH 01/12] atompisp: HAS_BL is never defined so lose it

2017-05-26 Thread Alan Cox
Kill off the HAS_BL define and the code and includes it brackets. We never
define HAS_BL or use that functionality.

Signed-off-by: Alan Cox 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css.c|  101 
 .../atomisp/pci/atomisp2/css2400/sh_css_firmware.c |   19 
 .../atomisp/pci/atomisp2/css2400/sh_css_internal.h |7 -
 3 files changed, 1 insertion(+), 126 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 81a21a0..19dc843 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -98,18 +98,12 @@ static int thread_alive;
 
 #include "isp/modes/interface/input_buf.isp.h"
 
-#if defined(HAS_BL)
-#include "support/bootloader/interface/ia_css_blctrl.h"
-#endif
 #if defined(HAS_RES_MGR)
 #include "components/acc_cluster/gen/host/acc_cluster.host.h"
 #endif
 
 /* Name of the sp program: should not be built-in */
 #define SP_PROG_NAME "sp"
-#if defined(HAS_BL)
-#define BL_PROG_NAME "bootloader"
-#endif
 /* Size of Refcount List */
 #define REFCOUNT_SIZE 1000
 
@@ -1571,34 +1565,7 @@ enable_interrupts(enum ia_css_irq_type irq_type)
 }
 
 #endif
-#if defined(HAS_BL)
-static bool sh_css_setup_blctrl_config(const struct ia_css_fw_info *fw,
-   const char *program,
-   ia_css_blctrl_cfg  
*blctrl_cfg)
-{
-   if((fw == NULL)||(blctrl_cfg == NULL))
-   return false;
-   blctrl_cfg->bl_entry = 0;
-   blctrl_cfg->program_name = (char *)(program);
-
-#if !defined(HRT_UNSCHED)
-   blctrl_cfg->ddr_data_offset =  fw->blob.data_source;
-   blctrl_cfg->dmem_data_addr = fw->blob.data_target;
-   blctrl_cfg->dmem_bss_addr = fw->blob.bss_target;
-   blctrl_cfg->data_size = fw->blob.data_size ;
-   blctrl_cfg->bss_size = fw->blob.bss_size;
-
-   blctrl_cfg->blctrl_state_dmem_addr = fw->info.bl.sw_state;
-   blctrl_cfg->blctrl_dma_cmd_list = fw->info.bl.dma_cmd_list;
-   blctrl_cfg->blctrl_nr_of_dma_cmds = fw->info.bl.num_dma_cmds;
 
-   blctrl_cfg->code_size = fw->blob.size;
-   blctrl_cfg->code  = fw->blob.code;
-   blctrl_cfg->bl_entry  = fw->info.bl.bl_entry; /* entry function ptr on 
Bootloader */
-#endif
-   return true;
-}
-#endif
 static bool sh_css_setup_spctrl_config(const struct ia_css_fw_info *fw,
const char * program,
ia_css_spctrl_cfg  
*spctrl_cfg)
@@ -1708,9 +1675,6 @@ ia_css_init(const struct ia_css_env *env,
 {
enum ia_css_err err;
ia_css_spctrl_cfg spctrl_cfg;
-#if defined(HAS_BL)
-   ia_css_blctrl_cfg blctrl_cfg;
-#endif
 
void (*flush_func)(struct ia_css_acc_fw *fw);
hrt_data select, enable;
@@ -1863,26 +1827,6 @@ ia_css_init(const struct ia_css_env *env,
return err;
}
 
-#if defined(HAS_BL)
-   if (!sh_css_setup_blctrl_config(_css_bl_fw, BL_PROG_NAME, 
_cfg))
-   return IA_CSS_ERR_INTERNAL_ERROR;
-   err = ia_css_blctrl_load_fw(_cfg);
-   if (err != IA_CSS_SUCCESS) {
-   IA_CSS_LEAVE_ERR(err);
-   return err;
-   }
-
-#ifdef ISP2401
-   err = ia_css_blctrl_add_target_fw_info(_css_sp_fw, IA_CSS_SP0,
-get_sp_code_addr(SP0_ID));
-
-#endif
-   if (err != IA_CSS_SUCCESS) {
-   IA_CSS_LEAVE_ERR(err);
-   return err;
-   }
-#endif /* HAS_BL */
-
 #if WITH_PC_MONITORING
if (!thread_alive) {
thread_alive++;
@@ -2667,9 +2611,6 @@ ia_css_uninit(void)
}
ia_css_spctrl_unload_fw(SP0_ID);
sh_css_sp_set_sp_running(false);
-#if defined(HAS_BL)
-   ia_css_blctrl_unload_fw();
-#endif
 #if defined(USE_INPUT_SYSTEM_VERSION_2) || 
defined(USE_INPUT_SYSTEM_VERSION_2401)
/* check and free any remaining mipi frames */
free_mipi_frames(NULL);
@@ -10588,39 +10529,6 @@ ia_css_pipe_get_isp_pipe_version(const struct 
ia_css_pipe *pipe)
return (unsigned int)pipe->config.isp_pipe_version;
 }
 
-#if defined(HAS_BL)
-#define BL_START_TIMEOUT_US 3000
-static enum ia_css_err
-ia_css_start_bl(void)
-{
-   enum ia_css_err err = IA_CSS_SUCCESS;
-   unsigned long timeout;
-
-   IA_CSS_ENTER("");
-   sh_css_start_bl();
-   /* waiting for the Bootloader to complete execution */
-   timeout = BL_START_TIMEOUT_US;
-   while((ia_css_blctrl_get_state() == BOOTLOADER_BUSY) && timeout) {
-   timeout--;
-   hrt_sleep();
-   }
-   ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-   "Bootloader state %d\n", ia_css_blctrl_get_state());
-   if (timeout == 0) {
-   

RE: [PATCH v5 3/7] media: i2c: max2175: Add MAX2175 support

2017-05-26 Thread Ramesh Shanmugasundaram
Hi Sakari,

Thanks for the review comments on the patches. Sorry for the late response as I 
was caught up with another work. 

I will incorporate your comments and rebase it on top of your branch. I see it 
is not there in media-tree master yet. Please let me know if there is a change 
in plan.

Thanks,
Ramesh

> Subject: Re: [PATCH v5 3/7] media: i2c: max2175: Add MAX2175 support
> 
> Hi Ramesh,
> 
> On Tue, May 09, 2017 at 02:37:34PM +0100, Ramesh Shanmugasundaram wrote:
> ...
> > +#include 
> > +#include 
> > +#include 
> 
> Could you rebase this on the V4L2 fwnode patchset here, please?
> 
> 
> 
> It depends on other patches which will reach media-tree master in next
> rc1, for now I've merged them here:
> 
> 
> 
> I'll send a pull request for media-tree once we have 4.12rc1 in media-tree
> master.
> 
> Thanks.
> 
> --
> Kind regards,
> 
> Sakari Ailus
> e-mail: sakari.ai...@iki.fi   XMPP: sai...@retiisi.org.uk


Re: [PATCH 1/3] [media] si2157: get chip id during probing

2017-05-26 Thread Steven Toth
>> ep: 81 l:9 08260080ff5901
>>
>> here you see all the  from the device.

You need to be able to see the traffic on the physical I2C bus in
order to help diagnose issues like this. You're going to want to see
ACKS/NAKS, clocks and other I2C bus activity.

You'll need to solder down scl/sda/gnd wiring to the PCB, I generally
attached to the eeprom which tends to have larger pins (details on
their respective datasheets).

It's not hard to do, but does require a small investment in hardware.

One the actual bus behavior is documented and understood, you'll
likely get a better technical discussion going on.

Send me a detailed picture of the PCB and I can probably help spot the
I2C bus for you, if you have a low cost bus analyzer and a soldering
iron.

-- 
Steven Toth - Kernel Labs
http://www.kernellabs.com


[PATCH 1/1] ad5820: unregister async sub-device

2017-05-26 Thread Sakari Ailus
The async sub-device was not unregistered in ad5820_remove() as it should
have been; do it now. Also remove the now-redundant
v4l2_device_unregister_subdev().

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

diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c
index 3d2a3c6..034ebf7 100644
--- a/drivers/media/i2c/ad5820.c
+++ b/drivers/media/i2c/ad5820.c
@@ -341,7 +341,7 @@ static int ad5820_remove(struct i2c_client *client)
struct v4l2_subdev *subdev = i2c_get_clientdata(client);
struct ad5820_device *coil = to_ad5820_device(subdev);
 
-   v4l2_device_unregister_subdev(>subdev);
+   v4l2_async_unregister_subdev(>subdev);
v4l2_ctrl_handler_free(>ctrls);
media_entity_cleanup(>subdev.entity);
mutex_destroy(>power_lock);
-- 
2.7.4



Re: [RFC PATCH 6/7] drm: add support for DisplayPort CEC-Tunneling-over-AUX

2017-05-26 Thread Daniel Vetter
On Fri, May 26, 2017 at 12:34 PM, Hans Verkuil  wrote:
>>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>>> index 78d7fc0ebb57..dd771ce8a3d0 100644
>>> --- a/drivers/gpu/drm/Kconfig
>>> +++ b/drivers/gpu/drm/Kconfig
>>> @@ -120,6 +120,9 @@ config DRM_LOAD_EDID_FIRMWARE
>>>default case is N. Details and instructions how to build your own
>>>EDID data are given in Documentation/EDID/HOWTO.txt.
>>>
>>> +config DRM_DP_CEC
>>> +bool
>>
>> We generally don't bother with a Kconfig for every little bit in drm, not
>> worth the trouble (yes I know there's some exceptions, but somehow they're
>> all from soc people). Just smash this into the KMS_HELPER one and live is
>> much easier for drivers. Also allows you to drop the dummy inline
>> functions.
>
> For all other CEC implementations I have placed it under a config option. The
> reason is that 1) CEC is an optional feature of HDMI and you may not actually
> want it, and 2) enabling CEC also pulls in the cec module.
>
> I still think turning this into a drm config option makes sense. This would
> replace the i915 config option I made in the next patch, i.e. this config 
> option
> is moved up one level.
>
> Your choice, though.

If there is a CEC option already, can we just reuse that one? I.e.
when it's enabled, we compile the drm dp cec helpers, if it's not, you
get the pile of dummy functions. drm_dp_cec.c should still be part of
drm_kms_helper.ko though I think (since the dp aux stuff is in there
anyway, doesn't make sense to split it).

I'm still not sold on Kconfig proliferation for optional features
(have one for the driver, that's imo enough), but if it exists already
not going to block it's use in drm. As long as it's minimally invasive
on the code and drivers don't have to care at all.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


[PATCH] davinci: vpif_capture: fix default pixel format for BT.656/BT.1120 video

2017-05-26 Thread Sekhar Nori
For both BT.656 and BT.1120 video, the pixel format
used by VPIF is Y/CbCr 4:2:2 in semi-planar format
(Luma in one plane and Chroma in another). This
corresponds to NV16 pixel format.

This is documented in section 36.2.3 of OMAP-L138
Technical Reference Manual, SPRUH77A.

The VPIF driver incorrectly sets the default format
to V4L2_PIX_FMT_YUV422P. Fix it.

Reported-by: Alejandro Hernandez 
Signed-off-by: Sekhar Nori 
---
 drivers/media/platform/davinci/vpif_capture.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index 44f702752d3a..128e92d1dd5a 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -513,7 +513,7 @@ static int vpif_update_std_info(struct channel_obj *ch)
if (ch->vpifparams.iface.if_type == VPIF_IF_RAW_BAYER)
common->fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SBGGR8;
else
-   common->fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV422P;
+   common->fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_NV16;
 
common->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 
@@ -917,8 +917,8 @@ static int vpif_enum_fmt_vid_cap(struct file *file, void  
*priv,
fmt->pixelformat = V4L2_PIX_FMT_SBGGR8;
} else {
fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-   strcpy(fmt->description, "YCbCr4:2:2 YC Planar");
-   fmt->pixelformat = V4L2_PIX_FMT_YUV422P;
+   strcpy(fmt->description, "YCbCr4:2:2 Semi-Planar");
+   fmt->pixelformat = V4L2_PIX_FMT_NV16;
}
return 0;
 }
@@ -946,8 +946,8 @@ static int vpif_try_fmt_vid_cap(struct file *file, void 
*priv,
if (pixfmt->pixelformat != V4L2_PIX_FMT_SBGGR8)
pixfmt->pixelformat = V4L2_PIX_FMT_SBGGR8;
} else {
-   if (pixfmt->pixelformat != V4L2_PIX_FMT_YUV422P)
-   pixfmt->pixelformat = V4L2_PIX_FMT_YUV422P;
+   if (pixfmt->pixelformat != V4L2_PIX_FMT_NV16)
+   pixfmt->pixelformat = V4L2_PIX_FMT_NV16;
}
 
common->fmt.fmt.pix.pixelformat = pixfmt->pixelformat;
-- 
2.9.0



Re: [RFC PATCH 6/7] drm: add support for DisplayPort CEC-Tunneling-over-AUX

2017-05-26 Thread Hans Verkuil
On 05/26/2017 09:18 AM, Daniel Vetter wrote:
> On Thu, May 25, 2017 at 05:06:25PM +0200, Hans Verkuil wrote:
>> From: Hans Verkuil 
>>
>> This adds support for the DisplayPort CEC-Tunneling-over-AUX
>> feature that is part of the DisplayPort 1.3 standard.
>>
>> Unfortunately, not all DisplayPort/USB-C to HDMI adapters with a
>> chip that has this capability actually hook up the CEC pin, so
>> even though a CEC device is created, it may not actually work.
>>
>> Signed-off-by: Hans Verkuil 
>> ---
>>  drivers/gpu/drm/Kconfig  |   3 +
>>  drivers/gpu/drm/Makefile |   1 +
>>  drivers/gpu/drm/drm_dp_cec.c | 196 
>> +++
>>  include/drm/drm_dp_helper.h  |  24 ++
>>  4 files changed, 224 insertions(+)
>>  create mode 100644 drivers/gpu/drm/drm_dp_cec.c
>>
>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>> index 78d7fc0ebb57..dd771ce8a3d0 100644
>> --- a/drivers/gpu/drm/Kconfig
>> +++ b/drivers/gpu/drm/Kconfig
>> @@ -120,6 +120,9 @@ config DRM_LOAD_EDID_FIRMWARE
>>default case is N. Details and instructions how to build your own
>>EDID data are given in Documentation/EDID/HOWTO.txt.
>>  
>> +config DRM_DP_CEC
>> +bool
> 
> We generally don't bother with a Kconfig for every little bit in drm, not
> worth the trouble (yes I know there's some exceptions, but somehow they're
> all from soc people). Just smash this into the KMS_HELPER one and live is
> much easier for drivers. Also allows you to drop the dummy inline
> functions.

For all other CEC implementations I have placed it under a config option. The
reason is that 1) CEC is an optional feature of HDMI and you may not actually
want it, and 2) enabling CEC also pulls in the cec module.

I still think turning this into a drm config option makes sense. This would
replace the i915 config option I made in the next patch, i.e. this config option
is moved up one level.

Your choice, though.

> The other nitpick: Pls kernel-doc the functions exported to drivers, and
> then pull them into Documentation/gpu/drm-kms-helpers.rst, next to the
> existing DP helper section.

Will do.

BTW, do you know if it is possible to detect when a DP-to-HDMI adapter is
connected as I discussed in my cover letter? That's my main open question
for this patch series.

Regarding the other thing I discussed in the cover letter about detecting if
the CEC pin is really hooked up: I think I shouldn't try to be smart. Yes, I
can try to poll for a TV, but that doesn't really say anything about whether
CEC is working or not since the TV itself may not have enabled CEC (actually
quite common).

One alternative might be to poll and, if no TV is detected, call dev_info to
let the user know that either there is no CEC-enabled TV, or the CEC pin isn't
connected.

I'm not sure if that helps the user or not.

Regards,

Hans

> 
> Thanks, Daniel



Re: [RFC PATCH 7/7] drm/i915: add DisplayPort CEC-Tunneling-over-AUX support

2017-05-26 Thread Hans Verkuil
On 05/26/2017 09:15 AM, Daniel Vetter wrote:
> On Thu, May 25, 2017 at 05:06:26PM +0200, Hans Verkuil wrote:
>> From: Hans Verkuil 
>>
>> Implement support for this DisplayPort feature.
>>
>> The cec device is created whenever it detects an adapter that
>> has this feature. It is only removed when a new adapter is connected
>> that does not support this. If a new adapter is connected that has
>> different properties than the previous one, then the old cec device is
>> unregistered and a new one is registered to replace the old one.
>>
>> Signed-off-by: Hans Verkuil 
> 
> Some small comments below.
> 
>> ---
>>  drivers/gpu/drm/i915/Kconfig| 11 ++
>>  drivers/gpu/drm/i915/intel_dp.c | 46 
>> +
>>  2 files changed, 53 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
>> index a5cd5dacf055..f317b13a1409 100644
>> --- a/drivers/gpu/drm/i915/Kconfig
>> +++ b/drivers/gpu/drm/i915/Kconfig
>> @@ -124,6 +124,17 @@ config DRM_I915_GVT_KVMGT
>>Choose this option if you want to enable KVMGT support for
>>Intel GVT-g.
>>  
>> +config DRM_I915_DP_CEC
>> +tristate "Enable DisplayPort CEC-Tunneling-over-AUX HDMI support"
>> +depends on DRM_I915 && CEC_CORE
>> +select DRM_DP_CEC
>> +help
>> +  Choose this option if you want to enable HDMI CEC support for
>> +  DisplayPort/USB-C to HDMI adapters.
>> +
>> +  Note: not all adapters support this feature, and even for those
>> +  that do support this often do not hook up the CEC pin.
> 
> Why Kconfig? There's not anything else optional in i915.ko (except debug
> stuff ofc), since generally just not worth the pain. Also doesn't seem to
> be wired up at all :-)

It selects DRM_DP_CEC, but you're right, it can be dropped.

> 
>> +
>>  menu "drm/i915 Debugging"
>>  depends on DRM_I915
>>  depends on EXPERT
>> diff --git a/drivers/gpu/drm/i915/intel_dp.c 
>> b/drivers/gpu/drm/i915/intel_dp.c
>> index ee77b519835c..38e17ee2548d 100644
>> --- a/drivers/gpu/drm/i915/intel_dp.c
>> +++ b/drivers/gpu/drm/i915/intel_dp.c
>> @@ -32,6 +32,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -1405,6 +1406,7 @@ static void intel_aux_reg_init(struct intel_dp 
>> *intel_dp)
>>  static void
>>  intel_dp_aux_fini(struct intel_dp *intel_dp)
>>  {
>> +cec_unregister_adapter(intel_dp->aux.cec_adap);
>>  kfree(intel_dp->aux.name);
>>  }
>>  
>> @@ -4179,6 +4181,33 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp)
>>  return -EINVAL;
>>  }
>>  
>> +static bool
>> +intel_dp_check_cec_status(struct intel_dp *intel_dp)
>> +{
>> +bool handled = false;
>> +
>> +for (;;) {
>> +u8 cec_irq;
>> +int ret;
>> +
>> +ret = drm_dp_dpcd_readb(_dp->aux,
>> +DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1,
>> +_irq);
>> +if (ret < 0 || !(cec_irq & DP_CEC_IRQ))
>> +return handled;
>> +
>> +cec_irq &= ~DP_CEC_IRQ;
>> +drm_dp_cec_irq(_dp->aux);
>> +handled = true;
>> +
>> +ret = drm_dp_dpcd_writeb(_dp->aux,
>> + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1,
>> + cec_irq);
>> +if (ret < 0)
>> +return handled;
>> +}
>> +}
> 
> Shouldn't the above be a helper in the cec library? Doesn't look i915
> specific to me at least ...

Good point, this can be moved to drm_dp_cec_irq().

> 
>> +
>>  static void
>>  intel_dp_retrain_link(struct intel_dp *intel_dp)
>>  {
>> @@ -4553,6 +4582,7 @@ intel_dp_set_edid(struct intel_dp *intel_dp)
>>  intel_dp->has_audio = intel_dp->force_audio == HDMI_AUDIO_ON;
>>  else
>>  intel_dp->has_audio = drm_detect_monitor_audio(edid);
>> +cec_s_phys_addr_from_edid(intel_dp->aux.cec_adap, edid);
>>  }
>>  
>>  static void
>> @@ -4562,6 +4592,7 @@ intel_dp_unset_edid(struct intel_dp *intel_dp)
>>  
>>  kfree(intel_connector->detect_edid);
>>  intel_connector->detect_edid = NULL;
>> +cec_phys_addr_invalidate(intel_dp->aux.cec_adap);
>>  
>>  intel_dp->has_audio = false;
>>  }
>> @@ -4582,13 +4613,17 @@ intel_dp_long_pulse(struct intel_connector 
>> *intel_connector)
>>  intel_display_power_get(to_i915(dev), intel_dp->aux_power_domain);
>>  
>>  /* Can't disconnect eDP, but you can close the lid... */
>> -if (is_edp(intel_dp))
>> +if (is_edp(intel_dp)) {
>>  status = edp_detect(intel_dp);
>> -else if (intel_digital_port_connected(to_i915(dev),
>> -  dp_to_dig_port(intel_dp)))
>> +} else if (intel_digital_port_connected(to_i915(dev),
>> +dp_to_dig_port(intel_dp))) {
>>  status = 

Re: [RFC PATCH 7/7] drm/i915: add DisplayPort CEC-Tunneling-over-AUX support

2017-05-26 Thread Hans Verkuil
On 05/26/2017 12:13 PM, Jani Nikula wrote:
> On Thu, 25 May 2017, Hans Verkuil  wrote:
>> @@ -4179,6 +4181,33 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp)
>>  return -EINVAL;
>>  }
>>  
>> +static bool
>> +intel_dp_check_cec_status(struct intel_dp *intel_dp)
>> +{
>> +bool handled = false;
>> +
>> +for (;;) {
>> +u8 cec_irq;
>> +int ret;
>> +
>> +ret = drm_dp_dpcd_readb(_dp->aux,
>> +DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1,
>> +_irq);
>> +if (ret < 0 || !(cec_irq & DP_CEC_IRQ))
>> +return handled;
>> +
>> +cec_irq &= ~DP_CEC_IRQ;
>> +drm_dp_cec_irq(_dp->aux);
>> +handled = true;
>> +
>> +ret = drm_dp_dpcd_writeb(_dp->aux,
>> + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1,
>> + cec_irq);
>> +if (ret < 0)
>> +return handled;
>> +}
> 
> DP sinks suck. Please add a limit to the loop.

Good to know. I wondered about that.

Regards,

Hans


Re: [RFC PATCH 7/7] drm/i915: add DisplayPort CEC-Tunneling-over-AUX support

2017-05-26 Thread Jani Nikula
On Thu, 25 May 2017, Hans Verkuil  wrote:
> @@ -4179,6 +4181,33 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp)
>   return -EINVAL;
>  }
>  
> +static bool
> +intel_dp_check_cec_status(struct intel_dp *intel_dp)
> +{
> + bool handled = false;
> +
> + for (;;) {
> + u8 cec_irq;
> + int ret;
> +
> + ret = drm_dp_dpcd_readb(_dp->aux,
> + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1,
> + _irq);
> + if (ret < 0 || !(cec_irq & DP_CEC_IRQ))
> + return handled;
> +
> + cec_irq &= ~DP_CEC_IRQ;
> + drm_dp_cec_irq(_dp->aux);
> + handled = true;
> +
> + ret = drm_dp_dpcd_writeb(_dp->aux,
> +  DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1,
> +  cec_irq);
> + if (ret < 0)
> + return handled;
> + }

DP sinks suck. Please add a limit to the loop.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center


Re: [RFC PATCH 5/7] drm/cec: Add CEC over Aux register definitions

2017-05-26 Thread Jani Nikula
On Thu, 25 May 2017, Hans Verkuil  wrote:
> From: Clint Taylor 
>
> Adding DPCD register definitions from the DP 1.3 specification for CEC
> over AUX support.
>
> V2: Add DP_ prefix to all defines.
> V3: missed prefixes from the ESI1 defines
>
> Cc: Jani Nikula 
>
> Reviewed-by: Jani Nikula 
> Signed-off-by: Clint Taylor 
> Signed-off-by: Jani Nikula 
> Link: 
> http://patchwork.freedesktop.org/patch/msgid/1492703263-11494-1-git-send-email-clinton.a.tay...@intel.com

This one's already in drm-next as

commit d753e41d475421543eaaea5f0feadba827f5fa01
Author: Clint Taylor 
Date:   Thu Apr 20 08:47:43 2017 -0700

drm/cec: Add CEC over Aux register definitions

BR,
Jani.


> ---
>  include/drm/drm_dp_helper.h | 59 
> +
>  1 file changed, 59 insertions(+)
>
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index c0bd0d7651a9..3f4ad709534e 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -603,6 +603,9 @@
>  #define DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0   0x2003   /* 1.2 */
>  
>  #define DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1   0x2004   /* 1.2 */
> +# define DP_RX_GTC_MSTR_REQ_STATUS_CHANGE(1 << 0)
> +# define DP_LOCK_ACQUISITION_REQUEST (1 << 1)
> +# define DP_CEC_IRQ  (1 << 2)
>  
>  #define DP_LINK_SERVICE_IRQ_VECTOR_ESI0 0x2005   /* 1.2 */
>  
> @@ -636,6 +639,62 @@
>  # define DP_VSC_EXT_CEA_SDP_SUPPORTED(1 << 6)  /* DP 
> 1.4 */
>  # define DP_VSC_EXT_CEA_SDP_CHAINING_SUPPORTED   (1 << 7)  /* DP 
> 1.4 */
>  
> +/* HDMI CEC tunneling over AUX DP 1.3 section 5.3.3.3.1 DPCD 1.4+ */
> +#define DP_CEC_TUNNELING_CAPABILITY0x3000
> +# define DP_CEC_TUNNELING_CAPABLE   (1 << 0)
> +# define DP_CEC_SNOOPING_CAPABLE(1 << 1)
> +# define DP_CEC_MULTIPLE_LA_CAPABLE (1 << 2)
> +
> +#define DP_CEC_TUNNELING_CONTROL   0x3001
> +# define DP_CEC_TUNNELING_ENABLE(1 << 0)
> +# define DP_CEC_SNOOPING_ENABLE (1 << 1)
> +
> +#define DP_CEC_RX_MESSAGE_INFO 0x3002
> +# define DP_CEC_RX_MESSAGE_LEN_MASK (0xf << 0)
> +# define DP_CEC_RX_MESSAGE_LEN_SHIFT0
> +# define DP_CEC_RX_MESSAGE_HPD_STATE(1 << 4)
> +# define DP_CEC_RX_MESSAGE_HPD_LOST (1 << 5)
> +# define DP_CEC_RX_MESSAGE_ACKED(1 << 6)
> +# define DP_CEC_RX_MESSAGE_ENDED(1 << 7)
> +
> +#define DP_CEC_TX_MESSAGE_INFO 0x3003
> +# define DP_CEC_TX_MESSAGE_LEN_MASK (0xf << 0)
> +# define DP_CEC_TX_MESSAGE_LEN_SHIFT0
> +# define DP_CEC_TX_RETRY_COUNT_MASK (0x7 << 4)
> +# define DP_CEC_TX_RETRY_COUNT_SHIFT4
> +# define DP_CEC_TX_MESSAGE_SEND (1 << 7)
> +
> +#define DP_CEC_TUNNELING_IRQ_FLAGS 0x3004
> +# define DP_CEC_RX_MESSAGE_INFO_VALID   (1 << 0)
> +# define DP_CEC_RX_MESSAGE_OVERFLOW (1 << 1)
> +# define DP_CEC_TX_MESSAGE_SENT (1 << 4)
> +# define DP_CEC_TX_LINE_ERROR   (1 << 5)
> +# define DP_CEC_TX_ADDRESS_NACK_ERROR   (1 << 6)
> +# define DP_CEC_TX_DATA_NACK_ERROR  (1 << 7)
> +
> +#define DP_CEC_LOGICAL_ADDRESS_MASK0x300E /* 0x300F word */
> +# define DP_CEC_LOGICAL_ADDRESS_0   (1 << 0)
> +# define DP_CEC_LOGICAL_ADDRESS_1   (1 << 1)
> +# define DP_CEC_LOGICAL_ADDRESS_2   (1 << 2)
> +# define DP_CEC_LOGICAL_ADDRESS_3   (1 << 3)
> +# define DP_CEC_LOGICAL_ADDRESS_4   (1 << 4)
> +# define DP_CEC_LOGICAL_ADDRESS_5   (1 << 5)
> +# define DP_CEC_LOGICAL_ADDRESS_6   (1 << 6)
> +# define DP_CEC_LOGICAL_ADDRESS_7   (1 << 7)
> +#define DP_CEC_LOGICAL_ADDRESS_MASK_2  0x300F /* 0x300E word */
> +# define DP_CEC_LOGICAL_ADDRESS_8   (1 << 0)
> +# define DP_CEC_LOGICAL_ADDRESS_9   (1 << 1)
> +# define DP_CEC_LOGICAL_ADDRESS_10  (1 << 2)
> +# define DP_CEC_LOGICAL_ADDRESS_11  (1 << 3)
> +# define DP_CEC_LOGICAL_ADDRESS_12  (1 << 4)
> +# define DP_CEC_LOGICAL_ADDRESS_13  (1 << 5)
> +# define DP_CEC_LOGICAL_ADDRESS_14  (1 << 6)
> +# define DP_CEC_LOGICAL_ADDRESS_15  (1 << 7)
> +
> +#define DP_CEC_RX_MESSAGE_BUFFER   0x3010
> +#define DP_CEC_TX_MESSAGE_BUFFER   0x3020
> +#define DP_CEC_MESSAGE_BUFFER_LENGTH 0x10
> +
>  /* DP 1.2 Sideband message defines */
>  /* peer device type - DP 1.2a Table 2-92 */
>  #define DP_PEER_DEVICE_NONE  0x0

-- 
Jani Nikula, Intel Open Source Technology Center


[PATCH 1/1] v4l2-ctrls.c: Implement unlocked variant of v4l2_ctrl_handler_setup()

2017-05-26 Thread Sakari Ailus
Sometimes the caller is already holding the control handler mutex and
using it to serialise something. Provide an unlocked variant of the same
function to be used in those cases.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 21 +++--
 include/media/v4l2-ctrls.h   | 13 +
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index ec42872..dec55d5 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -2444,14 +2444,16 @@ int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd)
 EXPORT_SYMBOL(v4l2_ctrl_subdev_log_status);
 
 /* Call s_ctrl for all controls owned by the handler */
-int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
+int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
 {
struct v4l2_ctrl *ctrl;
int ret = 0;
 
if (hdl == NULL)
return 0;
-   mutex_lock(hdl->lock);
+
+   lockdep_assert_held(hdl->lock);
+
list_for_each_entry(ctrl, >ctrls, node)
ctrl->done = false;
 
@@ -2476,7 +2478,22 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler 
*hdl)
if (ret)
break;
}
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(__v4l2_ctrl_handler_setup);
+
+int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
+{
+   int ret;
+
+   if (hdl == NULL)
+   return 0;
+
+   mutex_lock(hdl->lock);
+   ret = __v4l2_ctrl_handler_setup(hdl);
mutex_unlock(hdl->lock);
+
return ret;
 }
 EXPORT_SYMBOL(v4l2_ctrl_handler_setup);
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index bee1404..2d2aed5 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -458,6 +458,19 @@ static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
 }
 
 /**
+ * __v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
+ * to the handler to initialize the hardware to the current control values. The
+ * caller is responsible for acquiring the control handler mutex on behalf of
+ * __v4l2_ctrl_handler_setup().
+ * @hdl:   The control handler.
+ *
+ * Button controls will be skipped, as are read-only controls.
+ *
+ * If @hdl == NULL, then this just returns 0.
+ */
+int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
+
+/**
  * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
  * to the handler to initialize the hardware to the current control values.
  * @hdl:   The control handler.
-- 
2.7.4



Re: [PATCH] ov5670: Add Omnivision OV5670 5M sensor support

2017-05-26 Thread Sakari Ailus
Hi Chiranjeevi,

On Fri, May 26, 2017 at 01:19:59AM +, Rapolu, Chiranjeevi wrote:
> >> +/* Analog gain controls from sensor */
> >> +#define   ANALOG_GAIN_MIN 0
> >> +#define   ANALOG_GAIN_MAX 8191
> >> +#define   ANALOG_GAIN_STEP1
> >> +#define   ANALOG_GAIN_DEFAULT 128
> >> +
> >> +/* Exposure controls from sensor */
> >> +#define   EXPOSURE_MIN0
> >> +#define   EXPOSURE_MAX1048575
> >> +#define   EXPOSURE_STEP   1
> >> +#define   EXPOSURE_DEFAULT47232
> >
> >Are these values dependent on sensor configuration i.e. in the case of this
> >driver modes?
> >
> Default values for a given resolutions can be fine-tuned. I think it is up to
> the HAL/application as to what default exposure for a given resolution. Driver
> has the support to change per application.

How about the minimum and maximum values? Are they dependent on other
configuration?

...

> >> +/* Write a list of registers */
> >> +static int ov5670_write_regs(struct ov5670 *ov5670,
> >> +   const struct ov5670_reg *regs,
> >> +   int len)
> >
> >How about using unsigned int for len?
> >
> Now u32 len.
> >> +{
> >> +  struct i2c_client *client = v4l2_get_subdevdata(>sd);
> >> +  int i;
> >
> >i as well.
> >
> Now u32 i

An insigned int should do. Types with explicit widths should be only used
when the exact value ranges is known, e.g. a 32-bit or 16-bit register.

...

> >> +static int ov5670_set_stream(struct v4l2_subdev *sd, int enable)
> >> +{
> >> +  struct ov5670 *ov5670 = to_ov5670(sd);
> >> +  int ret = 0;
> >> +
> >> +  mutex_lock(>mutex);
> >> +  if (ov5670->streaming == enable) {
> >> +  mutex_unlock(>mutex);
> >> +  return 0;
> >> +  }
> >> +  mutex_unlock(>mutex);
> >> +
> >> +  if (enable) {
> >> +  ret = ov5670_prepare_streaming(ov5670);
> >
> >ov5670_prepare_streaming() and ov5670_start_streaming() are always called
> >sequientally. Could you combine the two?
> >
> >About locking --- you would likely benefit from an unlocked variant of
> >v4l2_ctrl_handler_setup(). I uploaded it here, let me know if it works for
> >you:
> >
> >
> >
> Tried unlocked __v4l2_ctrl_handler_setup(), working fine, used.
> Can you push this patch?

Great! I sent it to the list a moment ago. :-)

> >> +static struct i2c_driver ov5670_i2c_driver = {
> >
> >const?
> >
> Made const

I later on figured out this was probably a bad suggestion. The driver
registration changes the i2c_driver struct, causing a compiler warning.

> >> +  .driver = {
> >> +  .name = "ov5670",
> >> +  .owner = THIS_MODULE,
> >> +  .pm = _pm_ops,
> >> +  .acpi_match_table = ACPI_PTR(ov5670_acpi_ids),
> >> +  },
> >> +  .probe = ov5670_probe,
> >> +  .remove = ov5670_remove,
> >> +  .id_table = ov5670_id_table,
> >> +};
> >> +
> >> +module_i2c_driver(ov5670_i2c_driver);
> >> +
> >> +MODULE_AUTHOR("Rapolu, Chiranjeevi ");
> >> +MODULE_AUTHOR("Yang, Hyungwoo ");
> >> +MODULE_AUTHOR("Pu, Yuning ");
> >> +MODULE_DESCRIPTION("Omnivision ov5670 sensor driver");
> >> +MODULE_LICENSE("GPL");

-- 
Kind regards,

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


Re: [PATCH v5] dw9714: Initial driver for dw9714 VCM

2017-05-26 Thread Sakari Ailus
Hi Rajmohan,

Thankd for the update. A few more comments I missed earlier.

On Thu, May 25, 2017 at 06:50:35PM -0700, Rajmohan Mani wrote:
> DW9714 is a 10 bit DAC, designed for linear
> control of voice coil motor.
> 
> This driver creates a V4L2 subdevice and
> provides control to set the desired focus.
> 
> Signed-off-by: Rajmohan Mani 
> ---
> Changes in v5:
>   - Addressed review comments from Tomasz, Sakari and Sylwester on v4
>   of this patch
> Changes in v4:
>   - Addressed review comments from Tomasz
> Changes in v3:
>   - Addressed most of the review comments from Sakari
> on v1 of this patch
> Changes in v2:
> - Addressed review comments from Hans Verkuil
> - Fixed a debug message typo
> - Got rid of a return variable
> ---
>  drivers/media/i2c/Kconfig  |   9 ++
>  drivers/media/i2c/Makefile |   1 +
>  drivers/media/i2c/dw9714.c | 292 
> +
>  3 files changed, 302 insertions(+)
>  create mode 100644 drivers/media/i2c/dw9714.c
> 
> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index fd181c9..516e2f2 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -300,6 +300,15 @@ config VIDEO_AD5820
> This is a driver for the AD5820 camera lens voice coil.
> It is used for example in Nokia N900 (RX-51).
>  
> +config VIDEO_DW9714
> + tristate "DW9714 lens voice coil support"
> + depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER && 
> VIDEO_V4L2_SUBDEV_API

This would be better split on two lines.

> + ---help---
> +   This is a driver for the DW9714 camera lens voice coil.
> +   DW9714 is a 10 bit DAC with 120mA output current sink
> +   capability. This is designed for linear control of
> +   voice coil motors, controlled via I2C serial interface.
> +
>  config VIDEO_SAA7110
>   tristate "Philips SAA7110 video decoder"
>   depends on VIDEO_V4L2 && I2C
> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index 62323ec..987bd1f 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -21,6 +21,7 @@ obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
>  obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o
>  obj-$(CONFIG_VIDEO_SAA6752HS) += saa6752hs.o
>  obj-$(CONFIG_VIDEO_AD5820)  += ad5820.o
> +obj-$(CONFIG_VIDEO_DW9714)  += dw9714.o
>  obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o
>  obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o
>  obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o
> diff --git a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c
> new file mode 100644
> index 000..22c84de
> --- /dev/null
> +++ b/drivers/media/i2c/dw9714.c
> @@ -0,0 +1,292 @@
> +/*
> + * Copyright (c) 2015--2017 Intel Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License version
> + * 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DW9714_NAME  "dw9714"
> +#define DW9714_MAX_FOCUS_POS 1023
> +/*
> + * This acts as the minimum granularity of lens movement.
> + * Keep this value power of 2, so the control steps can be
> + * uniformly adjusted for gradual lens movement, with desired
> + * number of control steps.
> + */
> +#define DW9714_CTRL_STEPS16
> +#define DW9714_CTRL_DELAY_US 1000
> +/*
> + * S[3:2] = 0x00, codes per step for "Linear Slope Control"
> + * S[1:0] = 0x00, step period
> + */
> +#define DW9714_DEFAULT_S 0x0
> +#define DW9714_VAL(data, s) ((data) << 4 | (s))
> +
> +/* dw9714 device structure */
> +struct dw9714_device {
> + struct i2c_client *client;
> + struct v4l2_ctrl_handler ctrls_vcm;
> + struct v4l2_subdev sd;
> + u16 current_val;
> +};
> +
> +static inline struct dw9714_device *to_dw9714_vcm(struct v4l2_ctrl *ctrl)
> +{
> + return container_of(ctrl->handler, struct dw9714_device, ctrls_vcm);
> +}
> +
> +static inline struct dw9714_device *sd_to_dw9714_vcm(struct v4l2_subdev 
> *subdev)
> +{
> + return container_of(subdev, struct dw9714_device, sd);
> +}
> +
> +static int dw9714_i2c_write(struct i2c_client *client, u16 data)
> +{
> + int ret;
> + u16 val = cpu_to_be16(data);
> +
> + ret = i2c_master_send(client, (const char *), sizeof(val));
> + if (ret != sizeof(val)) {
> + dev_err(>dev, "I2C write fail\n");
> + return -EIO;
> + }
> + return 0;
> +}
> +
> +static int dw9714_t_focus_vcm(struct dw9714_device *dw9714_dev, u16 val)
> +{
> + struct i2c_client *client = dw9714_dev->client;
> +
> + dw9714_dev->current_val 

Re: [RFC PATCH 6/7] drm: add support for DisplayPort CEC-Tunneling-over-AUX

2017-05-26 Thread Daniel Vetter
On Thu, May 25, 2017 at 05:06:25PM +0200, Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> This adds support for the DisplayPort CEC-Tunneling-over-AUX
> feature that is part of the DisplayPort 1.3 standard.
> 
> Unfortunately, not all DisplayPort/USB-C to HDMI adapters with a
> chip that has this capability actually hook up the CEC pin, so
> even though a CEC device is created, it may not actually work.
> 
> Signed-off-by: Hans Verkuil 
> ---
>  drivers/gpu/drm/Kconfig  |   3 +
>  drivers/gpu/drm/Makefile |   1 +
>  drivers/gpu/drm/drm_dp_cec.c | 196 
> +++
>  include/drm/drm_dp_helper.h  |  24 ++
>  4 files changed, 224 insertions(+)
>  create mode 100644 drivers/gpu/drm/drm_dp_cec.c
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 78d7fc0ebb57..dd771ce8a3d0 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -120,6 +120,9 @@ config DRM_LOAD_EDID_FIRMWARE
> default case is N. Details and instructions how to build your own
> EDID data are given in Documentation/EDID/HOWTO.txt.
>  
> +config DRM_DP_CEC
> + bool

We generally don't bother with a Kconfig for every little bit in drm, not
worth the trouble (yes I know there's some exceptions, but somehow they're
all from soc people). Just smash this into the KMS_HELPER one and live is
much easier for drivers. Also allows you to drop the dummy inline
functions.

The other nitpick: Pls kernel-doc the functions exported to drivers, and
then pull them into Documentation/gpu/drm-kms-helpers.rst, next to the
existing DP helper section.

Thanks, Daniel

> +
>  config DRM_TTM
>   tristate
>   depends on DRM && MMU
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 59f0f9b696eb..22f1a17dfc8a 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -34,6 +34,7 @@ drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o 
> drm_probe_helper.o \
>   drm_simple_kms_helper.o drm_modeset_helper.o \
>   drm_scdc_helper.o
>  
> +drm_kms_helper-$(CONFIG_DRM_DP_CEC) += drm_dp_cec.o
>  drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
>  drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
>  drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o
> diff --git a/drivers/gpu/drm/drm_dp_cec.c b/drivers/gpu/drm/drm_dp_cec.c
> new file mode 100644
> index ..44c544ba53cb
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_dp_cec.c
> @@ -0,0 +1,196 @@
> +/*
> + * DisplayPort CEC-Tunneling-over-AUX support
> + *
> + * Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights 
> reserved.
> + *
> + * This program is free software; you may redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 2 of the License.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> + * SOFTWARE.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static int drm_dp_cec_adap_enable(struct cec_adapter *adap, bool enable)
> +{
> + struct drm_dp_aux *aux = cec_get_drvdata(adap);
> + ssize_t err = 0;
> +
> + if (enable)
> + err = drm_dp_dpcd_writeb(aux, DP_CEC_TUNNELING_CONTROL,
> +  DP_CEC_TUNNELING_ENABLE);
> + else
> + err = drm_dp_dpcd_writeb(aux, DP_CEC_TUNNELING_CONTROL, 0);
> + return (enable && err < 0) ? err : 0;
> +}
> +
> +static int drm_dp_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
> +{
> + struct drm_dp_aux *aux = cec_get_drvdata(adap);
> + u8 mask[2] = { 0x00, 0x80 };
> + ssize_t err;
> +
> + if (addr != CEC_LOG_ADDR_INVALID) {
> + u16 la_mask = adap->log_addrs.log_addr_mask;
> +
> + la_mask |= 0x8000 | (1 << addr);
> + mask[0] = la_mask & 0xff;
> + mask[1] = la_mask >> 8;
> + }
> + err = drm_dp_dpcd_write(aux, DP_CEC_LOGICAL_ADDRESS_MASK, mask, 2);
> + return (addr != CEC_LOG_ADDR_INVALID && err < 0) ? err : 0;
> +}
> +
> +static int drm_dp_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
> + u32 signal_free_time, struct cec_msg *msg)
> +{
> + struct drm_dp_aux *aux = cec_get_drvdata(adap);
> + unsigned int retries = attempts - 1;
> + ssize_t err;
> +
> + err = drm_dp_dpcd_write(aux, DP_CEC_TX_MESSAGE_BUFFER,
> +

Re: [RFC PATCH 7/7] drm/i915: add DisplayPort CEC-Tunneling-over-AUX support

2017-05-26 Thread Daniel Vetter
On Thu, May 25, 2017 at 05:06:26PM +0200, Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> Implement support for this DisplayPort feature.
> 
> The cec device is created whenever it detects an adapter that
> has this feature. It is only removed when a new adapter is connected
> that does not support this. If a new adapter is connected that has
> different properties than the previous one, then the old cec device is
> unregistered and a new one is registered to replace the old one.
> 
> Signed-off-by: Hans Verkuil 

Some small comments below.

> ---
>  drivers/gpu/drm/i915/Kconfig| 11 ++
>  drivers/gpu/drm/i915/intel_dp.c | 46 
> +
>  2 files changed, 53 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
> index a5cd5dacf055..f317b13a1409 100644
> --- a/drivers/gpu/drm/i915/Kconfig
> +++ b/drivers/gpu/drm/i915/Kconfig
> @@ -124,6 +124,17 @@ config DRM_I915_GVT_KVMGT
> Choose this option if you want to enable KVMGT support for
> Intel GVT-g.
>  
> +config DRM_I915_DP_CEC
> + tristate "Enable DisplayPort CEC-Tunneling-over-AUX HDMI support"
> + depends on DRM_I915 && CEC_CORE
> + select DRM_DP_CEC
> + help
> +   Choose this option if you want to enable HDMI CEC support for
> +   DisplayPort/USB-C to HDMI adapters.
> +
> +   Note: not all adapters support this feature, and even for those
> +   that do support this often do not hook up the CEC pin.

Why Kconfig? There's not anything else optional in i915.ko (except debug
stuff ofc), since generally just not worth the pain. Also doesn't seem to
be wired up at all :-)

> +
>  menu "drm/i915 Debugging"
>  depends on DRM_I915
>  depends on EXPERT
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index ee77b519835c..38e17ee2548d 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -32,6 +32,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1405,6 +1406,7 @@ static void intel_aux_reg_init(struct intel_dp 
> *intel_dp)
>  static void
>  intel_dp_aux_fini(struct intel_dp *intel_dp)
>  {
> + cec_unregister_adapter(intel_dp->aux.cec_adap);
>   kfree(intel_dp->aux.name);
>  }
>  
> @@ -4179,6 +4181,33 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp)
>   return -EINVAL;
>  }
>  
> +static bool
> +intel_dp_check_cec_status(struct intel_dp *intel_dp)
> +{
> + bool handled = false;
> +
> + for (;;) {
> + u8 cec_irq;
> + int ret;
> +
> + ret = drm_dp_dpcd_readb(_dp->aux,
> + DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1,
> + _irq);
> + if (ret < 0 || !(cec_irq & DP_CEC_IRQ))
> + return handled;
> +
> + cec_irq &= ~DP_CEC_IRQ;
> + drm_dp_cec_irq(_dp->aux);
> + handled = true;
> +
> + ret = drm_dp_dpcd_writeb(_dp->aux,
> +  DP_DEVICE_SERVICE_IRQ_VECTOR_ESI1,
> +  cec_irq);
> + if (ret < 0)
> + return handled;
> + }
> +}

Shouldn't the above be a helper in the cec library? Doesn't look i915
specific to me at least ...

> +
>  static void
>  intel_dp_retrain_link(struct intel_dp *intel_dp)
>  {
> @@ -4553,6 +4582,7 @@ intel_dp_set_edid(struct intel_dp *intel_dp)
>   intel_dp->has_audio = intel_dp->force_audio == HDMI_AUDIO_ON;
>   else
>   intel_dp->has_audio = drm_detect_monitor_audio(edid);
> + cec_s_phys_addr_from_edid(intel_dp->aux.cec_adap, edid);
>  }
>  
>  static void
> @@ -4562,6 +4592,7 @@ intel_dp_unset_edid(struct intel_dp *intel_dp)
>  
>   kfree(intel_connector->detect_edid);
>   intel_connector->detect_edid = NULL;
> + cec_phys_addr_invalidate(intel_dp->aux.cec_adap);
>  
>   intel_dp->has_audio = false;
>  }
> @@ -4582,13 +4613,17 @@ intel_dp_long_pulse(struct intel_connector 
> *intel_connector)
>   intel_display_power_get(to_i915(dev), intel_dp->aux_power_domain);
>  
>   /* Can't disconnect eDP, but you can close the lid... */
> - if (is_edp(intel_dp))
> + if (is_edp(intel_dp)) {
>   status = edp_detect(intel_dp);
> - else if (intel_digital_port_connected(to_i915(dev),
> -   dp_to_dig_port(intel_dp)))
> + } else if (intel_digital_port_connected(to_i915(dev),
> + dp_to_dig_port(intel_dp))) {
>   status = intel_dp_detect_dpcd(intel_dp);
> - else
> + if (status == connector_status_connected)
> + drm_dp_cec_configure_adapter(_dp->aux,
> +  intel_dp->aux.name, dev->dev);

Did you look into also 

Re: [PATCH v3 0/4] r8a7793 Gose video input support

2017-05-26 Thread Simon Horman
On Fri, May 19, 2017 at 03:07:00PM +0200, Ulrich Hecht wrote:
> Hi!
> 
> This is a by-the-datasheet implementation of analog and digital video input
> on the Gose board.
> 
> This revision adds new bindings that distinguish between ADV7180 variants
> with three and six input ports. There are numerous variants of this chip,
> but since all that have "CP" in their names have three inputs, and all that
> have "ST" have six, I have limited myself to two new compatible strings,
> "adv7180cp" and "adv7180st".
> 
> The digital input patch has received minor tweaks of the port names for
> consistency, and the Gose analog input patch has been modified to use the
> new bindings, and a composite video connector has been added.
> 
> CU
> Uli
> 
> 
> Changes since v2:
> - hdmi: port hdmi_con renamed to hdmi_con_out
> - adv7180: added new compatibility strings and bindings
> - composite: added connector, use new bindings
> 
> Changes since v1:
> - r8a7793.dtsi: added VIN2
> - modeled HDMI decoder input/output and connector
> - added "renesas,rcar-gen2-vin" compat strings
> - removed unnecessary "remote" node and aliases
> - set ADV7612 interrupt to GP4_2
> 
> 
> Ulrich Hecht (4):
>   ARM: dts: gose: add HDMI input

I have queued-up the above patch for v4.13.

>   media: adv7180: add adv7180cp, adv7180st compatible strings
>   media: adv7180: Add adv7180cp, adv7180st bindings
>   ARM: dts: gose: add composite video input

I have marked the above dts patch as "deferred" pending acceptance
of the binding. Please repost or otherwise ping me once that has happened.

>  .../devicetree/bindings/media/i2c/adv7180.txt  |  15 +++
>  arch/arm/boot/dts/r8a7793-gose.dts | 127 
> -
>  drivers/media/i2c/adv7180.c|   2 +
>  3 files changed, 142 insertions(+), 2 deletions(-)
> 
> -- 
> 2.7.4
> 


Re: [PATCH v2 1/1] [media] i2c: Add Omnivision OV5670 5M sensor support

2017-05-26 Thread kbuild test robot
Hi Chiranjeevi,

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.12-rc2 next-20170525]
[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/chiranjeevi-rapolu-intel-com/i2c-Add-Omnivision-OV5670-5M-sensor-support/20170526-134545
base:   git://linuxtv.org/media_tree.git master
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   drivers/media/i2c/ov5670.c: In function 'ov5670_prepare_streaming':
>> drivers/media/i2c/ov5670.c:2251:9: error: implicit declaration of function 
>> '__v4l2_ctrl_handler_setup' [-Werror=implicit-function-declaration]
 return __v4l2_ctrl_handler_setup(ov5670->sd.ctrl_handler);
^
   cc1: some warnings being treated as errors

vim +/__v4l2_ctrl_handler_setup +2251 drivers/media/i2c/ov5670.c

  2245  ret = ov5670_write_reg_list(ov5670, reg_list);
  2246  if (ret) {
  2247  dev_err(>dev, "%s failed to set mode\n", 
__func__);
  2248  return ret;
  2249  }
  2250  
> 2251  return __v4l2_ctrl_handler_setup(ov5670->sd.ctrl_handler);
  2252  }
  2253  
  2254  static int ov5670_start_streaming(struct ov5670 *ov5670)

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


.config.gz
Description: application/gzip