linux-2.6-microblaze.git
4 years agomedia: imx: imx7-mipi-csis: Implement the .enum_mbus_code() operation
Laurent Pinchart [Thu, 12 Mar 2020 23:47:22 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Implement the .enum_mbus_code() operation

Implement the subdev pad .enum_mbus_code() operation to enumerate media
bus codes on the sink and source pads.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Don't use imx-media-utils helpers
Laurent Pinchart [Thu, 12 Mar 2020 23:47:21 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Don't use imx-media-utils helpers

The imx7-mipi-csis only uses the imx_media_init_mbus_fmt() function from
the imx-media-utils helpers. The helpers don't support all the media bus
formats used by this driver, and are thus a bad fit. As the MIPI CSIS is
a standalone IP core that could be integrated in other SoCs, let's not
use the helper.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Cleanup includes
Laurent Pinchart [Thu, 12 Mar 2020 23:47:20 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Cleanup includes

Remove unneeded includes, add needed ones, and sort them alphabetically.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Remove link setup on source pad
Laurent Pinchart [Thu, 12 Mar 2020 23:47:19 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Remove link setup on source pad

The driver rejects enablement of multiple links on its source pad. This
isn't needed, as the CSIS doesn't care. Drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Align macro definitions
Laurent Pinchart [Thu, 12 Mar 2020 23:47:18 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Align macro definitions

The register macros at the top of the file have their value not aligned
on the same column, hindering readability. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Never set MIPI_CSIS_ISPCFG_ALIGN_32BIT
Laurent Pinchart [Thu, 12 Mar 2020 23:47:17 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Never set MIPI_CSIS_ISPCFG_ALIGN_32BIT

The MIPI_CSIS_ISPCFG_ALIGN_32BIT bit enables output of 32-bit data. The
driver sets it based on the select format, but no format uses a 32-bit
bus width, so the bit is never set in practice. This isn't likely to
change any time soon, as the CSI IP core connected at the output of the
CSIS doesn't support 32-bit data width. Hardcode the bit to 0.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Align image width based on format
Laurent Pinchart [Thu, 12 Mar 2020 23:47:16 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Align image width based on format

The total number of bits per line needs to be a multiple of 8, which
requires aligning the image width based on the format width. The
csis_pix_format structure contains a pix_width_alignment field that
serves this purpose, but the field is never set. Instead of fixing that,
calculate the alignment constraints based on the bus width for the
format, and drop the unneeded pix_width_alignment field.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Rename data_alignment field to width
Laurent Pinchart [Thu, 12 Mar 2020 23:47:15 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Rename data_alignment field to width

The csis_pix_format data_alignment field stores the bus width. Rename it
accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Add MEDIA_BUS_FMT_UYVY10_2X10 support
Laurent Pinchart [Thu, 12 Mar 2020 23:47:14 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Add MEDIA_BUS_FMT_UYVY10_2X10 support

Add support for 10-bit YUV 4:2:2.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Fix MEDIA_BUS_FMT_UYVY8_2X8 data alignment
Laurent Pinchart [Thu, 12 Mar 2020 23:47:13 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Fix MEDIA_BUS_FMT_UYVY8_2X8 data alignment

The MEDIA_BUS_FMT_UYVY8_2X8 format reports a data alignment of 16 bits,
which isn't correct as it is output on an 8-bit bus. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Expose correct YUV formats
Laurent Pinchart [Thu, 12 Mar 2020 23:47:12 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Expose correct YUV formats

The imx7-mipi-csis driver claims to support MEDIA_BUS_FMT_VYUY8_2X8 and
MEDIA_BUS_FMT_YUYV8_2X8, but this is not correct. When receiving
YUV 4:2:2 data on the CSI-2 bus, the output format is
MEDIA_BUS_FMT_UYVY8_2X8. Fix this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Add missing RAW formats
Laurent Pinchart [Thu, 12 Mar 2020 23:47:11 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Add missing RAW formats

Add support for all the missing 8-, 10-, 12- and 14-bit RAW formats.
This include all Bayer combinations, as well as greyscale. No media bus
code exist for Y14 so this is currently left out.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Centralize initialization of pad formats
Laurent Pinchart [Thu, 12 Mar 2020 23:47:10 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Centralize initialization of pad formats

Pad formats for the active configuration are manually initialized in
mipi_csis_subdev_init(), while pad formats for the TRY configurations
are initialized by the subdev .init_cfg() operation. This creates a risk
of the two configurations not being synchronized. Fix it by initializing
formats in the .init_cfg() operation only, and calling it from
mipi_csis_subdev_init().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Cleanup and fix subdev pad format handling
Laurent Pinchart [Thu, 12 Mar 2020 23:47:09 +0000 (00:47 +0100)]
media: imx: imx7-mipi-csis: Cleanup and fix subdev pad format handling

The subdev set pad format operation currently misbehaves in multiple ways:

- mipi_csis_try_format() unconditionally stores the format in the device
  state, even for V4L2_SUBDEV_FORMAT_TRY.

- The format is never stored in the pad cfg, but the pad cfg format
  always overwrites the format requested by the user.

- The sink format is not propagated to the source.

Fix all this by reworking the set format operation as follows:

1. For the source pad, turn set() into get() as the source format is not
   modifiable.
2. Validate the requested format and updated the stored format
   accordingly.
3. Return the format actually set.
4. Propagate the format from sink to source.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: venus: core: remove CNOC voting while device suspend
Mansur Alisha Shaik [Fri, 10 Apr 2020 07:17:25 +0000 (09:17 +0200)]
media: venus: core: remove CNOC voting while device suspend

The Venus driver is voting Configuration NoC during .probe but not clear
voting in .suspend. Because of this NoC is up during shutdown also. As a
consequence the whole device could leak energy while in .suspend.

So correct this by moving voting in .resume and unvoting
in .suspend

Signed-off-by: Mansur Alisha Shaik <mansur@codeaurora.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: venus: hfi_msgs.h: Replace zero-length array with flexible-array member
Gustavo A. R. Silva [Thu, 19 Mar 2020 22:22:29 +0000 (23:22 +0100)]
media: venus: hfi_msgs.h: Replace zero-length array with flexible-array member

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: venus: hfi_cmds.h: Replace zero-length array with flexible-array member
Gustavo A. R. Silva [Thu, 19 Mar 2020 22:21:05 +0000 (23:21 +0100)]
media: venus: hfi_cmds.h: Replace zero-length array with flexible-array member

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: venus: vdec: Use pmruntime autosuspend
Stanimir Varbanov [Thu, 30 Jan 2020 15:44:24 +0000 (16:44 +0100)]
media: venus: vdec: Use pmruntime autosuspend

Implement pmruntime autosuspend in video decoder. This will
allow to save power while the userspace is inactive for some
reasonable period of time. Here we power-off venus core clocks
and power domain and don't touch vcodec because it is under
hardware control. The later decision is made to simplify the
code and avoid a mess in the power management code.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: imgu: do not hold spinlock during freeing mmu page table
Bingbu Cao [Tue, 24 Mar 2020 04:16:48 +0000 (05:16 +0100)]
media: staging: imgu: do not hold spinlock during freeing mmu page table

ImgU need set the mmu page table in memory as uncached, and set back
to write-back when free the page table by set_memory_wb(),
set_memory_wb() can not do flushing without interrupt, so the spinlock
should not be hold during ImgU page alloc and free, the interrupt
should be enabled during memory cache flush.

This patch release spinlock before freeing pages table.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ipu3.rst: add yuv-downscaling into pipeline diagram
Bingbu Cao [Tue, 31 Mar 2020 13:00:40 +0000 (15:00 +0200)]
media: ipu3.rst: add yuv-downscaling into pipeline diagram

For ipu3 ImgU image processing, the frame data from TNR can feed into
DDR by Output Formatting System or feed into YUV downscaler to do YUV
downscaling for secondary output, which is usually used for display.
current ImgU image pipeline diagram misses the YUV downscaling,
this patch add it to aligh with actual hardware blocks.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging/intel-ipu3: Simplify single goto jump
Deepak R Varma [Mon, 30 Mar 2020 23:20:57 +0000 (01:20 +0200)]
media: staging/intel-ipu3: Simplify single goto jump

On successful node setup, the code jumps to a cleanup label to perform
nodes cleanup. This only call to cleanup using goto label can be
included in the for / if blocks to make it look more associated.

Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: doc-rst: add yavta test example in ipu3 docs
Bingbu Cao [Mon, 30 Mar 2020 09:05:14 +0000 (11:05 +0200)]
media: doc-rst: add yavta test example in ipu3 docs

This patch add yavta test command in ipu3.rst as an example on how to
run simple ImgU test using yavta.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ov5640: fix use of destroyed mutex
Tomi Valkeinen [Wed, 25 Mar 2020 12:20:00 +0000 (13:20 +0100)]
media: ov5640: fix use of destroyed mutex

v4l2_ctrl_handler_free() uses hdl->lock, which in ov5640 driver is set
to sensor's own sensor->lock. In ov5640_remove(), the driver destroys the
sensor->lock first, and then calls v4l2_ctrl_handler_free(), resulting
in the use of the destroyed mutex.

Fix this by calling moving the mutex_destroy() to the end of the cleanup
sequence, as there's no need to destroy the mutex as early as possible.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: stable@vger.kernel.org # v4.14+
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging/intel-ipu3: Remove extra blank lines
Deepak R Varma [Wed, 25 Mar 2020 20:56:44 +0000 (21:56 +0100)]
media: staging/intel-ipu3: Remove extra blank lines

Remove extra blank lines from the code blocks.

Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging/intel-ipu3: css: simplify expression
Deepak R Varma [Wed, 25 Mar 2020 20:38:24 +0000 (21:38 +0100)]
media: staging/intel-ipu3: css: simplify expression

An array index computed inside square brackets complicates the code
and also extends the line beyond 80 character. Add new variable to
compute array index separately and use it as an index during assignment.

Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging/intel-ipu3: Implement lock for stream on/off operations
Bingbu Cao [Thu, 26 Mar 2020 14:54:37 +0000 (15:54 +0100)]
media: staging/intel-ipu3: Implement lock for stream on/off operations

Currently concurrent stream off operations on ImgU nodes are not
synchronized, leading to use-after-free bugs (as reported by KASAN).

[  250.090724] BUG: KASAN: use-after-free in
ipu3_dmamap_free+0xc5/0x116 [ipu3_imgu]
[  250.090726] Read of size 8 at addr ffff888127b29bc0 by task
yavta/18836
[  250.090731] Hardware name: HP Soraka/Soraka, BIOS
Google_Soraka.10431.17.0 03/22/2018
[  250.090732] Call Trace:
[  250.090735]  dump_stack+0x6a/0xb1
[  250.090739]  print_address_description+0x8e/0x279
[  250.090743]  ? ipu3_dmamap_free+0xc5/0x116 [ipu3_imgu]
[  250.090746]  kasan_report+0x260/0x28a
[  250.090750]  ipu3_dmamap_free+0xc5/0x116 [ipu3_imgu]
[  250.090754]  ipu3_css_pool_cleanup+0x24/0x37 [ipu3_imgu]
[  250.090759]  ipu3_css_pipeline_cleanup+0x61/0xb9 [ipu3_imgu]
[  250.090763]  ipu3_css_stop_streaming+0x1f2/0x321 [ipu3_imgu]
[  250.090768]  imgu_s_stream+0x94/0x443 [ipu3_imgu]
[  250.090772]  ? ipu3_vb2_buf_queue+0x280/0x280 [ipu3_imgu]
[  250.090775]  ? vb2_dma_sg_unmap_dmabuf+0x16/0x6f [videobuf2_dma_sg]
[  250.090778]  ? vb2_buffer_in_use+0x36/0x58 [videobuf2_common]
[  250.090782]  ipu3_vb2_stop_streaming+0xf9/0x135 [ipu3_imgu]

Implemented a lock to synchronize imgu stream on / off operations and
the modification of streaming flag (in struct imgu_device), to prevent
these issues.

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: fix kernel-doc markups
Mauro Carvalho Chehab [Tue, 14 Apr 2020 10:09:12 +0000 (12:09 +0200)]
media: vimc: fix kernel-doc markups

There are several markups there that doesn't follow the
specs. Fields should be like:

@foo:

with a collon at the end. Also, continuation lines should
be aligned.

Failing to do that would cause kernel-doc to parse it wrong.
Some of the troubles will even cause warnings:

$ ./scripts/kernel-doc -none drivers/media/test_drivers/vimc/vimc-common.h
drivers/media/test_drivers/vimc/vimc-common.h:59: error: Cannot parse struct or union!
drivers/media/test_drivers/vimc/vimc-common.h:77: warning: Function parameter or member 'bpp' not described in 'vimc_pix_map'
drivers/media/test_drivers/vimc/vimc-common.h:120: warning: Function parameter or member 'pipe_cfg' not described in 'vimc_device'
drivers/media/test_drivers/vimc/vimc-common.h:120: warning: Function parameter or member 'ent_devs' not described in 'vimc_device'
drivers/media/test_drivers/vimc/vimc-common.h:120: warning: Function parameter or member 'mdev' not described in 'vimc_device'
drivers/media/test_drivers/vimc/vimc-common.h:120: warning: Function parameter or member 'v4l2_dev' not described in 'vimc_device'
drivers/media/test_drivers/vimc/vimc-common.h:137: warning: Function parameter or member 'add' not described in 'vimc_ent_type'
drivers/media/test_drivers/vimc/vimc-common.h:137: warning: Function parameter or member 'unregister' not described in 'vimc_ent_type'
drivers/media/test_drivers/vimc/vimc-common.h:137: warning: Function parameter or member 'release' not described in 'vimc_ent_type'
drivers/media/test_drivers/vimc/vimc-common.h:150: warning: Function parameter or member 'name' not described in 'vimc_ent_config'
drivers/media/test_drivers/vimc/vimc-common.h:150: warning: Function parameter or member 'type' not described in 'vimc_ent_config'
drivers/media/test_drivers/vimc/vimc-common.h:197: warning: bad line:                 flags of the pads

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vim2m: Remove unneeded buffer lock
Ezequiel Garcia [Sat, 28 Mar 2020 14:44:16 +0000 (15:44 +0100)]
media: vim2m: Remove unneeded buffer lock

This spinlock is used solely to call v4l2_m2m_buf_done().

Since buffers are obtained only after being removed
from the ready queue, there's no concurrent access, and
so no need for synchronization.

Remove the spinlock to make sure no one copies this pattern.

Some archaeology shows this is a small leftover from ancient code.
This driver (then called m2m_testdev) used the videobuf1 framework;
commit d80ee38cd845 ("[media] v4l: mem2mem: port m2m_testdev to vb2")
converted it to videobuf2. The spinlock was then no longer needed,
and this simply went unnoticed.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: add vimc_ent_type struct for the callbacks of entities
Dafna Hirschfeld [Tue, 31 Mar 2020 18:45:15 +0000 (20:45 +0200)]
media: vimc: add vimc_ent_type struct for the callbacks of entities

Since each vimc entity type is defined by the
callbacks implementation, it is a good idea to
add a struct to hold these callbacks.

Each vimc entity then declare its type in the file for
the entity.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: fix issues in documentation in vimc-common.h
Dafna Hirschfeld [Sat, 28 Mar 2020 07:52:53 +0000 (08:52 +0100)]
media: vimc: fix issues in documentation in vimc-common.h

There are some missing and extra fields and typos in
structs documentations in vimc-common.h. Fix it.

[mchehab+huawei@kernel.org: add a missing ':' after @bayer field]
Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: keep the error value when adding an entity fails
Dafna Hirschfeld [Sat, 28 Mar 2020 07:52:52 +0000 (08:52 +0100)]
media: vimc: keep the error value when adding an entity fails

Currently when the 'add' callback of an entity fails, a
NULL is returned. This hides the error code of the failure
and always returns -EINVAL.

Replace return NULL with return ERR_PTR(ret) to improve debugging.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: handle error in vimc_add_subdevs
Dafna Hirschfeld [Sat, 28 Mar 2020 07:52:51 +0000 (08:52 +0100)]
media: vimc: handle error in vimc_add_subdevs

In case the 'add' callback of an entity fails,
then all other entities should unregister and released.
This should be done inside vimc_add_subdevs so that
the function handles its own failure.

In order to call vimc_unregister_subdevs and vimc_release_subdevs from
vimc_add_subdevs, the order of the function should change.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: remove the function vimc_unregister
Dafna Hirschfeld [Sat, 28 Mar 2020 07:52:50 +0000 (08:52 +0100)]
media: vimc: remove the function vimc_unregister

The function vimc_unregister is called only from
one place in the code and has only 3 lines so it
has no justification.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: coda: jpeg: support optimized huffman tables
Adrian Ratiu [Tue, 24 Mar 2020 16:04:29 +0000 (17:04 +0100)]
media: coda: jpeg: support optimized huffman tables

Each jpeg can have the huffman tables optimized for its specific content
meaning that the table lenghts and values don't match the standard table
of substitutions so there's no reason to hardcode and expect the standard
lengths, otherwise we just end up rejecting optimized jpegs altogether.

Tested on CODA960.

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: coda: lock capture queue wakeup against decoder stop command
Philipp Zabel [Wed, 18 Mar 2020 18:35:36 +0000 (19:35 +0100)]
media: coda: lock capture queue wakeup against decoder stop command

Similar to commit 9ee50a9489f1 ("media: coda: lock capture queue wakeup
against encoder stop command"), make sure that a JPEG decoder stop
command running concurrently with a decoder finish_run always either
flags the last returned buffer or wakes up the capture queue to signal
the end of stream condition afterwards.

This was not necessary for BIT processor contexts because of the need to
release the bitstream buffer with the stream end condition. In contrast,
the JPEG decoder can be finished with decoding the image between the
time the application queues the last output buffer and the time it
issues the decoder stop command.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: coda: mark last capture buffer
Philipp Zabel [Wed, 18 Mar 2020 18:35:35 +0000 (19:35 +0100)]
media: coda: mark last capture buffer

If a JPEG decoding application queues the last capture and output
buffers, issues a decoder stop command after the decoding is already
done, and then dequeues the last capture buffer, it is not marked as
last. Detect this condition in the decoder stop command and mark the
last buffer on the capture done list.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: coda: split marking last meta into helper function
Philipp Zabel [Wed, 18 Mar 2020 18:35:34 +0000 (19:35 +0100)]
media: coda: split marking last meta into helper function

Split marking the last metadata entry into a helper function to simplify
coda_decoder_cmd.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: coda: jpeg: add CODA960 JPEG decoder support
Philipp Zabel [Wed, 18 Mar 2020 18:35:33 +0000 (19:35 +0100)]
media: coda: jpeg: add CODA960 JPEG decoder support

This patch adds JPEG decoding support for CODA960, handling the JPEG
hardware directly. A separate JPEG decoder video device is created due
to the separate hardware unit and different supported pixel formats.
While the hardware can not change subsampling on the fly, it can decode
4:2:2 subsampled JPEG images into YUV422P.

[m.felsch@pengutronix.de: fix qsequence counting by explicitly
 checking for the !use_bit case]
[hverkuil-cisco@xs4all.nl: fix 'warning: missing braces around initializer']
[mchehab+huawei@kernel.org: fix 'BRACES: Unbalanced braces around else statement']

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: add v4l2 JPEG helpers
Philipp Zabel [Wed, 18 Mar 2020 18:35:32 +0000 (19:35 +0100)]
media: add v4l2 JPEG helpers

Add helpers for JPEG header parsing. They allow both scanning for marker
segment positions and later parsing the segments individually, as
required by s5p-jpeg, as well as parsing all headers in one go, as
required by coda-vpu. The frame header is always parsed, as basically
all decoders are interested in width, height, and number of components.
For convenience, the JPEG chroma subsampling factors are decoded into a
v4l2_jpeg_chroma_subsampling enum.

Only baseline and extended sequential DCT encoded JPEGs with 8-bit or
12-bit precision with up to four components are supported.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: coda: round up decoded buffer size for all codecs
Philipp Zabel [Wed, 18 Mar 2020 18:35:31 +0000 (19:35 +0100)]
media: coda: round up decoded buffer size for all codecs

The BIT decoders always write 16x16 macroblocks. Align stride and height to
avoid spilling luma data into the top of the chroma planes.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-common: Add BGR666 to v4l2_format_info
Dafna Hirschfeld [Mon, 16 Mar 2020 07:01:23 +0000 (08:01 +0100)]
media: v4l2-common: Add BGR666 to v4l2_format_info

Add V4L2_PIX_FMT_BGR666 to the format table.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: doc-rst: in the RGB formats table add '-' in undefined bits
Dafna Hirschfeld [Mon, 16 Mar 2020 15:56:26 +0000 (16:56 +0100)]
media: doc-rst: in the RGB formats table add '-' in undefined bits

In the table of the RGB formats, add an explicit '-' signs
to cells that contain undefined bits.
This makes it more clear how many bits and bytes are used
for each format.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx.rst: Add example media graphs
Steve Longerbeam [Thu, 19 Mar 2020 22:59:36 +0000 (23:59 +0100)]
media: imx.rst: Add example media graphs

Add the media graph topologies for the i.MX6Q SabreSD and SabreAuto.
This makes it easier to understand the topology and follow the
entity descriptions in the following sections.

Also clarify that the SabreSD and SabreLite media pipeline config examples
are for the i.MX6Q boards.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-common: change the pixel_enc of V4L2_PIX_FMT_GREY to YUV
Dafna Hirschfeld [Mon, 23 Mar 2020 17:36:18 +0000 (18:36 +0100)]
media: v4l2-common: change the pixel_enc of V4L2_PIX_FMT_GREY to YUV

V4L2_PIX_FMT_GREY format is Ycbcr format without
the color data, therefore its pixel_enc should
set to V4L2_PIXEL_ENC_YUV.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: usb: pvrusb2: convert to use i2c_new_client_device()
Wolfram Sang [Thu, 26 Mar 2020 21:09:46 +0000 (22:09 +0100)]
media: usb: pvrusb2: convert to use i2c_new_client_device()

Move away from the deprecated API.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Mike Isely <isely@pobox.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: usb: hdpvr: convert to use i2c_new_client_device()
Wolfram Sang [Thu, 26 Mar 2020 21:09:45 +0000 (22:09 +0100)]
media: usb: hdpvr: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: usb: cx231xx: convert to use i2c_new_client_device()
Wolfram Sang [Thu, 26 Mar 2020 21:09:44 +0000 (22:09 +0100)]
media: usb: cx231xx: convert to use i2c_new_client_device()

Move away from the deprecated API and make use of the fact that
unregistering devices is NULL- and ERR_PTR-safe.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: marvell-ccic: convert to use i2c_new_client_device()
Wolfram Sang [Thu, 26 Mar 2020 21:09:43 +0000 (22:09 +0100)]
media: marvell-ccic: convert to use i2c_new_client_device()

Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: pci: saa7134: convert to use i2c_new_client_device()
Wolfram Sang [Thu, 26 Mar 2020 21:09:42 +0000 (22:09 +0100)]
media: pci: saa7134: convert to use i2c_new_client_device()

Move away from the deprecated API.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: pci: cx88: convert to use i2c_new_client_device()
Wolfram Sang [Thu, 26 Mar 2020 21:09:41 +0000 (22:09 +0100)]
media: pci: cx88: convert to use i2c_new_client_device()

Move away from the deprecated API and make use of the fact that
unregistering devices is NULL- and ERR_PTR-safe.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: dt-bindings: rockchip-vpu: Convert bindings to json-schema
Ezequiel Garcia [Thu, 26 Mar 2020 19:13:43 +0000 (20:13 +0100)]
media: dt-bindings: rockchip-vpu: Convert bindings to json-schema

Convert Rockchip VPU (Hantro IP block) codec driver documentation to
json-schema.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: hantro: Refactor for V4L2 API spec compliancy
Ezequiel Garcia [Wed, 25 Mar 2020 21:34:37 +0000 (22:34 +0100)]
media: hantro: Refactor for V4L2 API spec compliancy

Refactor how S_FMT and TRY_FMT are handled, and also make sure
internal initial format and format reset are done properly.

The latter is achieved by making sure the same hantro_{set,try}_fmt
helpers are called on all paths that set the format (which is
part of the driver state).

This commit removes the following v4l2-compliance warnings:

test VIDIOC_G_FMT: OK
fail: v4l2-test-formats.cpp(711): Video Capture Multiplanar: TRY_FMT(G_FMT) != G_FMT
test VIDIOC_TRY_FMT: FAIL
fail: v4l2-test-formats.cpp(1116): Video Capture Multiplanar: S_FMT(G_FMT) != G_FMT
test VIDIOC_S_FMT: FAIL

Reported-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: hantro: Move H264 motion vector calculation to a helper
Ezequiel Garcia [Wed, 25 Mar 2020 21:34:36 +0000 (22:34 +0100)]
media: hantro: Move H264 motion vector calculation to a helper

Move the extra bytes calculation that are needed for H264
motion vector to a helper. This is just a cosmetic cleanup.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: hantro: Remove unneeded hantro_dec_buf_finish
Ezequiel Garcia [Wed, 25 Mar 2020 21:34:35 +0000 (22:34 +0100)]
media: hantro: Remove unneeded hantro_dec_buf_finish

Since now .buf_prepare takes care of setting the
buffer payload size, we can get rid of this,
at least for decoders.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: hantro: Use v4l2_m2m_buf_done_and_job_finish
Ezequiel Garcia [Wed, 25 Mar 2020 21:34:34 +0000 (22:34 +0100)]
media: hantro: Use v4l2_m2m_buf_done_and_job_finish

Let the core sort out the nuances of returning buffers
to userspace, by using the v4l2_m2m_buf_done_and_job_finish
helper.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: hantro: Set buffers' zeroth plane payload in .buf_prepare
Ezequiel Garcia [Wed, 25 Mar 2020 21:34:33 +0000 (22:34 +0100)]
media: hantro: Set buffers' zeroth plane payload in .buf_prepare

Buffers' zeroth plane payload size is calculated at format
negotiation time, and so it can be set in .buf_prepare.

Keep in mind that, to make this change easier, hantro_buf_prepare
is refactored, using the cedrus driver as reference. This results
in cleaner code as byproduct.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-mem2mem: return CAPTURE buffer first
Ezequiel Garcia [Wed, 25 Mar 2020 21:34:32 +0000 (22:34 +0100)]
media: v4l2-mem2mem: return CAPTURE buffer first

When the request API is used, typically an OUTPUT (src) buffer
will be part of a request. A userspace process will be typically
blocked, waiting on the request file descriptor.

Returning the OUTPUT (src) buffer will wake-up such processes,
who will immediately attempt to dequeue the CAPTURE buffer,
only to find it's still unavailable.

Therefore, change v4l2_m2m_buf_done_and_job_finish returning
the CAPTURE (dst) buffer first, to avoid signalling the request
file descriptor prematurely, i.e. before the CAPTURE buffer is done.

When the request API is not used, this change should have
no impact.

Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agoRevert "media: Kconfig: better support hybrid TV devices"
Mauro Carvalho Chehab [Tue, 14 Apr 2020 09:00:30 +0000 (11:00 +0200)]
Revert "media: Kconfig: better support hybrid TV devices"

Changing from "depends on" to "select" may cause some
side-effects. This patch is not ready to be merged yet,
as it requires some adjustments.

So, let's revert it.

This reverts commit a3b91d8bd1e034c8ed89d3f55243478af97a0a52.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: get rid of Documentation/media/
Mauro Carvalho Chehab [Tue, 10 Mar 2020 12:57:48 +0000 (13:57 +0100)]
media: docs: get rid of Documentation/media/

Now that everything got moved, we can get rid of the
old media directory.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: add an uAPI chapter for driver-specific stuff
Mauro Carvalho Chehab [Fri, 6 Mar 2020 07:50:46 +0000 (08:50 +0100)]
media: docs: add an uAPI chapter for driver-specific stuff

There are some uAPI stuff that are driver-specific. Add them
to the main media uAPI body.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: move driver-specific info to driver-api
Mauro Carvalho Chehab [Wed, 4 Mar 2020 14:54:10 +0000 (15:54 +0100)]
media: docs: move driver-specific info to driver-api

Those documents don't really describe the driver API.

Instead, they contain development-specific information.

Yet, as the main index file describes the content of it as:

"how specific kernel subsystems work
 from the point of view of a kernel developer"

It seems to be the better fit.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: move user-facing docs to the admin guide
Mauro Carvalho Chehab [Wed, 4 Mar 2020 12:08:03 +0000 (13:08 +0100)]
media: docs: move user-facing docs to the admin guide

Most of the driver-specific documentation is meant to help
users of the media subsystem.

Move them to the admin-guide.

It should be noticed, however, that several of those files
are outdated and will require further work in order to make
them useful again.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: move fourcc file to the uAPI document
Mauro Carvalho Chehab [Fri, 6 Mar 2020 07:34:41 +0000 (08:34 +0100)]
media: docs: move fourcc file to the uAPI document

This file gives a hint about how fourcc should be named.

It is on a very weird place, as such kind of thing belongs to the
uAPI guide.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: kAPI docs: move them to driver-api
Mauro Carvalho Chehab [Wed, 4 Mar 2020 09:50:14 +0000 (10:50 +0100)]
media: docs: kAPI docs: move them to driver-api

All those documents describe the media driver API. So, move
them to the right place within the Kernel documentation.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: move uAPI book to userspace-api/media
Mauro Carvalho Chehab [Wed, 4 Mar 2020 09:21:39 +0000 (10:21 +0100)]
media: docs: move uAPI book to userspace-api/media

Since 2017, there is an space reserved for userspace API,
created by changeset 1d596dee3862 ("docs: Create a user-space API guide").

As the media subsystem was one of the first subsystems to use
Sphinx, until this patch, we were keeping things on a separate
place.

Let's just use the new location, as having all uAPI altogether
will likely make things easier for developers.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split uAPI info from imx.rst
Mauro Carvalho Chehab [Thu, 5 Mar 2020 07:33:37 +0000 (08:33 +0100)]
media: docs: split uAPI info from imx.rst

This file contains both driver develompent documentation and
userspace API.

Split on two, as they're usually read by different audiences.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split uAPI info from omap3isp.rst
Mauro Carvalho Chehab [Thu, 5 Mar 2020 06:59:19 +0000 (07:59 +0100)]
media: docs: split uAPI info from omap3isp.rst

This file contains both driver develompent documentation and
userspace API.

Split on two, as they're usually read by different audiences.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split uAPI info from saa7134-devel.rst
Mauro Carvalho Chehab [Thu, 5 Mar 2020 06:48:35 +0000 (07:48 +0100)]
media: docs: split uAPI info from saa7134-devel.rst

This file contains both driver develompent documentation and
userspace API.

Split on two, as they're usually read by different audiences.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split uAPI info from fimc.rst
Mauro Carvalho Chehab [Thu, 5 Mar 2020 06:38:55 +0000 (07:38 +0100)]
media: docs: split uAPI info from fimc.rst

This file contains both driver develompent documentation and
userspace API.

Split on two, as they're usually read by different audiences.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split uAPI info from davinci-vpbe.rst
Mauro Carvalho Chehab [Thu, 5 Mar 2020 06:36:13 +0000 (07:36 +0100)]
media: docs: split uAPI info from davinci-vpbe.rst

This file contains both driver develompent documentation and
userspace API.

Split on two, as they're usually read by different audiences.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: cx18-streams.c: fix broken references to docs
Mauro Carvalho Chehab [Fri, 6 Mar 2020 05:26:59 +0000 (06:26 +0100)]
media: docs: cx18-streams.c: fix broken references to docs

There are two places inside this file that points to the
cx2341x documentation, with was split into two. Looking
at changeset dcc0ef88209a
("V4L/DVB (10442): cx18: Fixes for enforcing when Encoder Raw VBI params can be set")
with added those comments, it was originally pointing to:

Documentation/video4linux/cx2341x/fw-encoder-api.txt

Well, the firmware details went to

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split cx2341x.rst into different audiences
Mauro Carvalho Chehab [Thu, 5 Mar 2020 06:30:50 +0000 (07:30 +0100)]
media: docs: split cx2341x.rst into different audiences

This file contains both driver develompent documentation
(basically, firmware documentation) and IVTV-specific
documentation about VBI and raw formats, focused on uAPI
development.

Split on two, as they're usually read by different audiences.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split development info from cx88.rst
Mauro Carvalho Chehab [Thu, 5 Mar 2020 06:25:55 +0000 (07:25 +0100)]
media: docs: split development info from cx88.rst

This file contains both admin and development stuff. Split on
two, as they're usually read by different audiences.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split development info from bttv.rst
Mauro Carvalho Chehab [Thu, 5 Mar 2020 06:24:17 +0000 (07:24 +0100)]
media: docs: split development info from bttv.rst

This file contains both admin and development stuff. Split on
two, as they're usually read by different audiences.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split vimc.rst into devel and admin parts
Mauro Carvalho Chehab [Wed, 4 Mar 2020 16:10:12 +0000 (17:10 +0100)]
media: docs: split vimc.rst into devel and admin parts

The vimc driver has some kerneldoc markups, plus admin info.
Split it into two files.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split meye.rst into admin and uAPI docs
Mauro Carvalho Chehab [Wed, 4 Mar 2020 15:24:52 +0000 (16:24 +0100)]
media: docs: split meye.rst into admin and uAPI docs

Instead of placing both info from admin PoV and uAPI at the
same place, split into two separate documents.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split ci.rst into uAPI and user guide docs
Mauro Carvalho Chehab [Wed, 4 Mar 2020 13:31:12 +0000 (14:31 +0100)]
media: docs: split ci.rst into uAPI and user guide docs

The ci.rst file contains two parts: the first one describing
how to use the CA high level interface; the second one with
uAPI internals.

Split this on two separate files, adding the uAPI bits
to the DVB ca.rst configuration.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: split cpia2.rst on two files
Mauro Carvalho Chehab [Wed, 4 Mar 2020 15:15:25 +0000 (16:15 +0100)]
media: docs: split cpia2.rst on two files

In order to be able to better organize the subsystem, split the
cpia2 information on two files: one user-facing and another one
from Kernel development PoV.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: move soc-camera.rst to staging
Mauro Carvalho Chehab [Thu, 5 Mar 2020 06:49:04 +0000 (07:49 +0100)]
media: docs: move soc-camera.rst to staging

As the entire soc_camera driver is on staging to be removed
soon, let's place there its documentation too.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: docs: avermedia.rst: mark a table as such
Mauro Carvalho Chehab [Wed, 4 Mar 2020 11:53:28 +0000 (12:53 +0100)]
media: docs: avermedia.rst: mark a table as such

There's a table on this file, with aren't using the ReST
markups. Fix that.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: don't use visible for device type select
Mauro Carvalho Chehab [Wed, 25 Mar 2020 15:33:35 +0000 (16:33 +0100)]
media: Kconfig: don't use visible for device type select

While making the menu invisible seemed a good idea, there's
a drawback: when the menu is not visible, it is not parsing
the "default" dependency.

So, instead, let's just avoid the items at the menu to be
prompted, by using the "prompt ... if" construction.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: i2c/Kconfig: reorganize items there
Mauro Carvalho Chehab [Wed, 25 Mar 2020 14:56:15 +0000 (15:56 +0100)]
media: i2c/Kconfig: reorganize items there

Right now, there are I2C drivers that don't depend on
camera support before and after those.

Move the camera support drivers to the end, and add
a notice at the "endif", in order to make easier to
maintain and to avoid adding extra dependencies at
the other i2c/*/Kconfig files.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: Better organize the per-API options
Mauro Carvalho Chehab [Wed, 25 Mar 2020 10:15:15 +0000 (11:15 +0100)]
media: Kconfig: Better organize the per-API options

After this change, the menu is displayed like above.

1) When filtering is not active:

    --- Multimedia support
        [ ]   Filter devices by their types
        [*]   Autoselect ancillary drivers (tuners, sensors, i2c, spi, frontends)
              Media core support  --->
              Video4Linux options  --->
              Media controller options  --->
              Digital TV options  --->
              HDMI CEC options  --->
              Media drivers  --->

2) When filtering is active:

    --- Multimedia support
        [*]   Filter devices by their types
        [*]   Autoselect ancillary drivers (tuners, sensors, i2c, spi, frontends)
              Media device types  --->
              Video4Linux options  --->
              Media controller options  --->
              Digital TV options  --->
              HDMI CEC options  --->
              Media drivers  --->

The per-API menu will only be displayed if the corresponding
core support is enabled.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: on !EMBEDDED && !EXPERT, enable driver filtering
Mauro Carvalho Chehab [Tue, 24 Mar 2020 13:29:57 +0000 (14:29 +0100)]
media: Kconfig: on !EMBEDDED && !EXPERT, enable driver filtering

Advanced and embedded users know what to do, so, by default,
they will likely want to be able to open the entire set of
Kconfig media options.

Normal "poor" users usually needs more help when setting
stuff, so let's open an more simplified version to them by
default.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: move the position of sub-driver autoselection
Mauro Carvalho Chehab [Tue, 24 Mar 2020 13:24:41 +0000 (14:24 +0100)]
media: Kconfig: move the position of sub-driver autoselection

Let's place the sub-driver-autoselection option just below
the device filtering one, as it also controls a filter menu,
with is not even visible if !EXPERT && !EMBEDDED.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: place all options under a sub-menu
Mauro Carvalho Chehab [Tue, 24 Mar 2020 13:09:23 +0000 (14:09 +0100)]
media: Kconfig: place all options under a sub-menu

That should make easier for people setting the media
subsystem config options, as they'll be split by the
type of functionality that will be enabled.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: move media controller core select to main Kconfig
Mauro Carvalho Chehab [Tue, 24 Mar 2020 12:59:23 +0000 (13:59 +0100)]
media: Kconfig: move media controller core select to main Kconfig

Let's place the main API selections at the media/Kconfig file,
as this way we can better organize things.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: move V4L2 subdev API to v4l2-core/Kconfig
Mauro Carvalho Chehab [Tue, 24 Mar 2020 12:50:33 +0000 (13:50 +0100)]
media: Kconfig: move V4L2 subdev API to v4l2-core/Kconfig

This option is part of V4L2 API extra functionality set.
Move it to be at the v4l2-core/Kconfig, where it belongs,
cleaning the main Kconfig file.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: move DVB-specific options to dvb-core/Kconfig
Mauro Carvalho Chehab [Tue, 24 Mar 2020 12:47:11 +0000 (13:47 +0100)]
media: Kconfig: move DVB-specific options to dvb-core/Kconfig

In order to cleanup the main media Kconfig, move the DVB-core
specific options to dvb-core/Kconfig.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: move CEC-specific options to cec/Kconfig
Mauro Carvalho Chehab [Tue, 24 Mar 2020 12:41:57 +0000 (13:41 +0100)]
media: Kconfig: move CEC-specific options to cec/Kconfig

There's no need to have the CEC definitions inside the
media Kconfig, as the Kconfig parser doesn't require
symbols to be declared before their usages.

With that, the main Kconfig menu becomes cleaner.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: warn if drivers are filtered
Mauro Carvalho Chehab [Thu, 26 Mar 2020 08:44:13 +0000 (09:44 +0100)]
media: Kconfig: warn if drivers are filtered

As per a tester feedback, add an option to report when
the drivers are filtered at the Kconfig menu.

Cc: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: make filtering devices optional
Mauro Carvalho Chehab [Tue, 24 Mar 2020 10:36:10 +0000 (11:36 +0100)]
media: Kconfig: make filtering devices optional

The per-device option selection is a feature that some
developers love, while others hate...

So, let's make both happy by making it optional.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: use a sub-menu to select supported devices
Mauro Carvalho Chehab [Tue, 24 Mar 2020 09:25:09 +0000 (10:25 +0100)]
media: Kconfig: use a sub-menu to select supported devices

The media subsystem has hundreds of driver-specific options.
The *_SUPPORT config options work as a sort of filter,
allowing to reduce its complexity for users that won't
want to dig into thousands of options they don't need.

Yet, it the filtering options are becoming large. So, let's
place it on a sub-menu.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: reorganize the drivers menu options
Mauro Carvalho Chehab [Tue, 24 Mar 2020 09:14:15 +0000 (10:14 +0100)]
media: Kconfig: reorganize the drivers menu options

The comments before some of the drivers support look
weird, because their Kconfig have their own "comment"
directive inside it. So, rearrange them to make it
look a little nicer for the ones with are not too
familiar with the media system.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig files: use select for V4L2 subdevs and MC
Mauro Carvalho Chehab [Wed, 25 Mar 2020 14:36:56 +0000 (15:36 +0100)]
media: Kconfig files: use select for V4L2 subdevs and MC

There are lots of drivers that only work when the media controller
and/or the V4L2 subdev APIs are present.

Right now, someone need to first enable those APIs before
using those drivers.

Well, ideally, drivers, should, instead *optionally*
depend on it, in order for PC camera drivers to be able to use
them, but nowadays most drivers are UVC cameras, with don't
require a sensor driver.

So, be it.

Let's instead make them select the MEDIA_CONTROLLER and the
SUBDEV API, in order to make easier for people to be able
of enabling them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: dvb-core: Kconfig: default to use dynamic minors
Mauro Carvalho Chehab [Wed, 25 Mar 2020 14:01:25 +0000 (15:01 +0100)]
media: dvb-core: Kconfig: default to use dynamic minors

All modern Linux distributions nowadays use udev or some
alternative (like systemd). So, it makes sense to change
the default to use dynamic minors.

Please notice that this default doesn't enable any code.
It just changes the dvb-core behavior.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: add SPDX headers on Kconfig and Makefile files
Mauro Carvalho Chehab [Thu, 26 Mar 2020 15:13:16 +0000 (16:13 +0100)]
media: add SPDX headers on Kconfig and Makefile files

Most of media Kconfig/Makefile files already has SPDX,
but there are a few ones still missing. Add it to them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: fix selection for test drivers
Mauro Carvalho Chehab [Thu, 26 Mar 2020 14:47:25 +0000 (15:47 +0100)]
media: Kconfig: fix selection for test drivers

There are some long-time mistakes related to build test
drivers, with regards to depends on/select. Also, as we
now want to build any test driver without needing to
enable anything else, change the logic in order to properly
filter them.

Please notice that the PCI skeleton is somewhat an
exception, as it requires to select *both* SAMPLES and
MEDIA_TEST_SUPPORT. I almost changed it to be either one,
but decided to keep it as-is, as this is something that
we don't really need to be included on any distribution.

The only reason for someone to build it is for COMPILE_TEST
purposes.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: better support hybrid TV devices
Mauro Carvalho Chehab [Wed, 25 Mar 2020 07:36:36 +0000 (08:36 +0100)]
media: Kconfig: better support hybrid TV devices

Right now, if one has an hybrid TV card, it has to select
both analog and digital TV support, as otherwise the needed
core support won't be selected.

Change the logic to auto-select the core support for those
drivers, as this is a way more intuitive.

It should be noticed that, as now both DVB_CORE and VIDEO_DEV
defaults depends on selecting a hybrid cards, we had to remove
the explicit dependencies there, in order to avoid circular
dependencies.

That requires some tricks:

1) the prompt should not be not visible when an hybrid card
   is selected, as the user shold not change it.

2) When a media hybrid device is selected, the modular
   option for DVB_CORE and VIDEO_DEV will follow the
   MEDIA_SUPPORT dependency, as we can't have a core
   built with "y" with a driver built as module.

Note: while here, moved two pure V4L2 PCI drivers out of the
"hybrid" part of config and consider pvrusb2 as an hybrid
device.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Kconfig: simplify some dependencies
Mauro Carvalho Chehab [Wed, 25 Mar 2020 08:59:18 +0000 (09:59 +0100)]
media: Kconfig: simplify some dependencies

both DVB_CORE and VIDEO_DEV already depends on MEDIA_SUPPORT,
as they're below an if block.

So, remove this double dependency.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>