gpio: make gpiod_direction_output take a logical value

The documentation was not clear about whether
gpio_direction_output should take a logical value or the physical
level on the output line, i.e. whether the ACTIVE_LOW status
would be taken into account.

This converts gpiod_direction_output to use the logical level
and adds a new gpiod_direction_output_raw for the raw value.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

This backports commit ef70bbe1aaa612f75360e5df5952fddec50b7ca9 from
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
i2c: pca954x: Use the descriptor-based GPIO API

The ID-based GPIO API pushes handling of GPIO polarity to drivers.
Simplify the driver by switching to the descriptor-based GPIO API.

This also fixes a mismatch between the pca954x DT bindings that document
a "reset-gpios" property and the driver that requests a "reset-gpio"
property.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
i2c: pca954x: Fix compilation without CONFIG_GPIOLIB

The pca954x driver recently switched to the GPIO descriptor API without
including the correct <linux/gpio/consumer.h> header. This breaks
compilation without CONFIG_GPIOLIB.

drivers/i2c/muxes/i2c-mux-pca954x.c: In function ‘pca954x_probe’:
drivers/i2c/muxes/i2c-mux-pca954x.c:204:2: error: implicit declaration
of function ‘devm_gpiod_get’ [-Werror=implicit-function-declaration]
  gpio = devm_gpiod_get(&client->dev, "reset");
  ^
drivers/i2c/muxes/i2c-mux-pca954x.c:204:7: warning: assignment makes
pointer from integer without a cast [enabled by default]
  gpio = devm_gpiod_get(&client->dev, "reset");
       ^
drivers/i2c/muxes/i2c-mux-pca954x.c:206:3: error: implicit declaration
of function ‘gpiod_direction_output’
[-Werror=implicit-function-declaration]
   gpiod_direction_output(gpio, 0);
   ^
cc1: some warnings being treated as errors
make[3]: *** [drivers/i2c/muxes/i2c-mux-pca954x.o] Error 1

Fix it by including the right header.

Reported-by: Jim Davis <jim.epost@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jingoo Han <jg1.han@samsung.com>
drm: adv7511: Add regcache_mark_dirty() in probe()

Mark the register cache as dirty in probe(), otherwise the regcache doesn't
get synced properly in adv7511_encoder_dpms(). This results in some issue,
such as output format mismatch between adv7511 and some monitor.

Signed-off-by: Hyun Kwon <hyunk@xilinx.com>
media: xilinx: vipp: Add devicetree bindings documentation

Add devicetree bindings documentation for the Xilinx Video IP pipeline driver.

Signed-off-by: Hyun Kwon <hyunk@xilinx.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Revert "media: xilinx: dma: Workaround for bytesperline"

This reverts commit b4859c939e1febb638e23accc1c3a66b72e10ccc.
Zynq Base TRD LogiCVC DRM integration requires programming
bytesperline field i.e stride is not same as width.
So we need to get rid of this workaround and send mplayer
fix to its mailing list.

Signed-off-by: Radhey Shyam Pandey <radheys@xilinx.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
media: xilinx: Added DMA error handling

Validate dma tx descriptor returned from
dmaengine_prep_slave_single() and reports
error if any.
Next dequeue operation fails with -ENODEV

Signed-off-by: Radhey Shyam Pandey <radheys@xilinx.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
media: xilinx: Fix error handling

Fix error handling in xvip_graph_dma_init()
Avoid multiple free of vb2 dma context

Signed-off-by: Radhey Shyam Pandey <radheys@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
media: xilinx: Reordered mutexes initialization

Reordered mutexes initialization so that there is no
need of destroying mutex incase media_entity_init()
fails.

Signed-off-by: Radhey Shyam Pandey <radheys@xilinx.com>
media: xilinx: Fix "Reordered mutexes init" commit

Follow Up Flag: Follow up
Flag Status: Flagged

Restored earlier mutexes initialization
sequence and instead fix error handling for
media_entity_init.

Signed-off-by: Radhey Shyam Pandey <radheys@xilinx.com>
media: xilinx: Set format description in enum_fmt

Add a description field to the xvip_video_format structure and use it to
fill the format description during format enumeration.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
v4l2-ctrls: Add unlocked version of v4l2_ctrl_modify_range

The new control range might depend on the value of the same or another
control. Drivers thus need to read control values and modify the range
atomically, which requires locking the control handler manually outside
of v4l2_ctrl_modify_range().

Remove control handler locking from v4l2_ctrl_modify_range(), rename it
to __v4l2_ctrl_modify_range() and add a static inline wrapper called
v4l2_ctrl_modify_range() that locks the control handler.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media: xilinx: tpg: Default to the color bars test pattern

Accessing the TPG registers requires an external input clock, otherwise
an external abort exception will be triggered.

Defaulting to passthrough mode switches the timing mux to the external
clock at initialization time. If the external clock isn't provided (for
instance because the input hardware is disconnected), this results in a
kernel crash when the TPG is initialized.

Fix this by defaulting to a test pattern.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media: xilinx: tpg: Disallow switching passthrough mode during streaming

Due to the externally supplied video timings, passthrough mode can't be
switched during video streaming, as the switch wouldn't be synchronized
to vertical sync. Allow modifying the test pattern while the stream is
active, but keep passthrough mode configuration fixed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media: xilinx: tpg: Make horizontal and vertical blanking configurable

In order to match the capture frame rate with the display frame rate,
video timings need to be configurable by userspace. Expose the
horizontal and vertical blanking through controls. The synchronization
pulses widths and locations don't matter for all practical purposes,
hardcode them to working values.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media: xilinx: tpg: Ignore unconnected input ports

When the TPG is synthesized with an input port without any input
connected, passthrough mode must not be enabled otherwise an external
abort exception will be generated. To ensure correct operation don't
allow passthrough mode when the input port doesn't have an endpoint.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media: xilinx: Add HLS core driver

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
adv7604: Update recommended writes for the adv7611

Update the recommended writes to those mentioned in the Rev 1.5 version of the
ADV7611 Register Settings Recommendations document released by Analog Devices.
The document does not mention why the recommended settings have been updated,
but presumably those are more fine tuned settings that can enhance performance
in some cases.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
media: xilinx: Move and rename xilinx v4l2 controls header file

Rename the xilinx v4l2 controls header and move it to the UAPI
include directory so it gets exported when running
'make headers_install'. Fix all references to this file.

Signed-off-by: Christian Kohn <christian.kohn@xilinx.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media: xilinx: Remove global control handler

Follow Up Flag: Follow up
Flag Status: Flagged

Inheriting subdev controls on video nodes doesn't work in the general
case, as we have no control of what IP cores are included in the
pipeline. Even a simple linear pipeline could have several identical
controls when it includes several instances of IP cores of the same
family (two HLS cores for instance).

Controls should be accessed directly on subdev nodes. Remove the global
control handler to prevent control inheritance.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>