History log of /linux-master/drivers/media/v4l2-core/v4l2-common.c
Revision Date Author Comments
# a68e88e2 08-Jan-2024 Sakari Ailus <sakari.ailus@linux.intel.com>

media: v4l: Add a helper for setting up link-frequencies control

Add a helper for obtaining supported link frequencies in form most drivers
need them. The result is a bitmap of supported controls.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 287fe160 13-Dec-2023 Laurent Pinchart <laurent.pinchart@ideasonboard.com>

media: v4l2-subdev: Turn .[gs]_frame_interval into pad operations

The subdev .[gs]_frame_interval are video operations, but they operate
on pads (and even on streams). Not only is this confusing, it causes
practical issues for drivers as the operations don't receive a subdev
state pointer, requiring manual state handling.

To improve the situation, turn the operations into pad operations, and
extend them to receive a state pointer like other pad operations.

While at it, rename the operations to .[gs]et_frame_interval at the same
time to match the naming scheme of other pad operations. This isn't
strictly necessary, but given that all drivers using those operations
need to be modified, handling the rename separately would generate more
churn for very little gain (if at all).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> # for imx-media
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # for tegra-video
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>


# 57e3f1cf 07-Nov-2023 Jacopo Mondi <jacopo.mondi@ideasonboard.com>

media: v4l2-common: Add 10bpp RGB formats info

Video4Linux2 defines 3 RGB formats with 10 bits per color components
plus two optional alpha bits such that a pixel is then stored in a 4
bytes word.

Add a format info for the 3 10-bits RGB formats to the
v4l2_format_info() table in v4l2-common.c.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 1dff2beb 28-Jul-2023 Mingjia Zhang <mingjia.zhang@mediatek.com>

media: mediatek: vcodec: Add capture format to support 10bit raster mode

Define one uncompressed capture format V4L2_PIX_FMT_MT2110R in order to
support 10bit for H264 in mt8195.

Signed-off-by: Mingjia Zhang <mingjia.zhang@mediatek.com>
Co-developed-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>


# 6afcc2b0 28-Jul-2023 Mingjia Zhang <mingjia.zhang@mediatek.com>

media: mediatek: vcodec: Add capture format to support 10bit tile mode

Define one uncompressed capture format V4L2_PIX_FMT_MT2110T in order to
support 10bit for AV1/VP9/HEVC in mt8195.

Signed-off-by: Mingjia Zhang <mingjia.zhang@mediatek.com>
Co-developed-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>


# fc91af07 03-May-2023 Benjamin Gaignard <benjamin.gaignard@collabora.com>

media: Add NV15_4L4 pixel format

NV15_4L4 is the 10-bits per component 4x4 tiled format.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 86c256be 03-May-2023 Nicolas Dufresne <nicolas.dufresne@collabora.com>

media: v4l2-common: Add support for fractional bpp

Fraction bytes-per-pixel exist for some packed format. You will find
notably on Rockhip platform that 10bit data is stored fully packed,
meaning that there is 1.25 pixels per bytes. This can be represented
with the fraction 5/4 and can be used to scale the width into a
bytesperline.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 302b988c 21-Mar-2023 Ming Qian <ming.qian@nxp.com>

media: Add ABGR64_12 video format

ABGR64_12 is a reversed RGB format with alpha channel last,
12 bits per component like ABGR32,
expanded to 16bits.
Data in the 12 high bits, zeros in the 4 low bits,
arranged in little endian order.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# da0b7a40 21-Mar-2023 Ming Qian <ming.qian@nxp.com>

media: Add BGR48_12 video format

BGR48_12 is a reversed RGB format with 12 bits per component like BGR24,
expanded to 16bits.
Data in the 12 high bits, zeros in the 4 low bits,
arranged in little endian order.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 99c95496 21-Mar-2023 Ming Qian <ming.qian@nxp.com>

media: Add YUV48_12 video format

YUV48_12 is a YUV format with 12-bits per component like YUV24,
expanded to 16bits.
Data in the 12 high bits, zeros in the 4 low bits,
arranged in little endian order.

[hverkuil: replaced a . by ,]

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# a178dd3b 21-Mar-2023 Ming Qian <ming.qian@nxp.com>

media: Add Y212 v4l2 format info

Y212 is a YUV format with 12-bits per component like YUYV,
expanded to 16bits.
Data in the 12 high bits, zeros in the 4 low bits,
arranged in little endian order.

Add the missing v4l2 foramt info of Y212

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# aa108040 21-Mar-2023 Ming Qian <ming.qian@nxp.com>

media: Add P012 and P012M video format

P012 is a YUV format with 12-bits per component with interleaved UV,
like NV12, expanded to 16 bits.
Data in the 12 high bits, zeros in the 4 low bits,
arranged in little endian order.
And P012M has two non contiguous planes.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 6ba8b8d4 09-Sep-2022 Michael Grzeschik <m.grzeschik@pengutronix.de>

media: v4l: move helper functions for fractions from uvc to v4l2-common

The functions uvc_simplify_fraction and uvc_fraction_to_interval are
generic helpers which are also useful for other v4l2 drivers. This patch
moves them to v4l2-common.

Tested-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20220909221335.15033-2-m.grzeschik@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3c8e19d3 06-Jul-2022 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

media: Add P010 tiled format

Add P010 tiled format

[rebased, updated pixel format name and added description]

Tested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 5374d8fb 19-May-2022 Benjamin Gaignard <benjamin.gaignard@collabora.com>

media: Add P010 video format

P010 is a YUV format with 10-bits per component with interleaved UV.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 683f71eb 04-Aug-2021 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

media: Add NV12_4L4 tiled format

This format is produced by VeriSilicon Hantro G2 and VC8000D cores.
It is a simple 4x4 tiling layout in a linear way.

The pixel format was introduced by GStreamer using FourCC VT12,
so let's stick to it.

Link: https://gstreamer.freedesktop.org/documentation/video/video-format.html

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>


# 67012d97 18-Feb-2021 Andrey Konovalov <andrey.konovalov@linaro.org>

media: v4l: common: v4l2_get_link_freq: add printing a warning

Print a warning if V4L2_CID_LINK_FREQ control is not implemented.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
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>


# 2984a99f 17-Dec-2020 Sakari Ailus <sakari.ailus@linux.intel.com>

media: v4l: common: Fix naming of v4l2_get_link_rate

Rename v4l2_get_link_rate() as v4l2_get_link_freq(). What the function
returns is the frequency of the link; rename it to reflect the name of the
control where the information is obtained.

Fixes: 1b888b3cebef ("media: v4l: Add a helper for obtaining the link frequency")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 1b888b3c 13-Oct-2020 Sakari Ailus <sakari.ailus@linux.intel.com>

media: v4l: Add a helper for obtaining the link frequency

Add a helper for obtaining the link frequency from transmitter drivers.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# e31cf2f4 08-Jun-2020 Mike Rapoport <rppt@kernel.org>

mm: don't include asm/pgtable.h if linux/mm.h is already included

Patch series "mm: consolidate definitions of page table accessors", v2.

The low level page table accessors (pXY_index(), pXY_offset()) are
duplicated across all architectures and sometimes more than once. For
instance, we have 31 definition of pgd_offset() for 25 supported
architectures.

Most of these definitions are actually identical and typically it boils
down to, e.g.

static inline unsigned long pmd_index(unsigned long address)
{
return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
}

static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
{
return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
}

These definitions can be shared among 90% of the arches provided
XYZ_SHIFT, PTRS_PER_XYZ and xyz_page_vaddr() are defined.

For architectures that really need a custom version there is always
possibility to override the generic version with the usual ifdefs magic.

These patches introduce include/linux/pgtable.h that replaces
include/asm-generic/pgtable.h and add the definitions of the page table
accessors to the new header.

This patch (of 12):

The linux/mm.h header includes <asm/pgtable.h> to allow inlining of the
functions involving page table manipulations, e.g. pte_alloc() and
pmd_alloc(). So, there is no point to explicitly include <asm/pgtable.h>
in the files that include <linux/mm.h>.

The include statements in such cases are remove with a simple loop:

for f in $(git grep -l "include <linux/mm.h>") ; do
sed -i -e '/include <asm\/pgtable.h>/ d' $f
done

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Cain <bcain@codeaurora.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greentime Hu <green.hu@gmail.com>
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: Guo Ren <guoren@kernel.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Ley Foon Tan <ley.foon.tan@intel.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nick Hu <nickhu@andestech.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vincent Chen <deanbo422@gmail.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Link: http://lkml.kernel.org/r/20200514170327.31389-1-rppt@kernel.org
Link: http://lkml.kernel.org/r/20200514170327.31389-2-rppt@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 58d4c14e 16-Mar-2020 Dafna Hirschfeld <dafna.hirschfeld@collabora.com>

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>


# 7ca02435 23-Mar-2020 Dafna Hirschfeld <dafna.hirschfeld@collabora.com>

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>


# b373f84d 06-Oct-2019 Benoit Parrot <bparrot@ti.com>

media: v4l2-common: add RGB565 and RGB55 to v4l2_format_info

Add RGB565 and RGB555 to the v4l2_format_info table.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# d5a897c8 06-Oct-2019 Benoit Parrot <bparrot@ti.com>

media: v4l2-common: add pixel encoding support

It is often useful to figure out if a pixel_format is either YUV or RGB
especially for driver who can perform the pixel encoding conversion.

Instead of having each driver implement its own "is_this_yuv/rgb"
function based on a restricted set of pixel value, it is better to do
this in centralized manner.

We therefore add a pixel_enc member to the v4l2_format_info structure to
quickly identify the related pixel encoding.
And add helper functions to check pixel encoding.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 02283b98 15-Aug-2019 Ezequiel Garcia <ezequiel@collabora.com>

media: v4l2-core: move i2c helpers out of v4l2-common.c

Separate the i2c helpers to v4l2-i2c.c, in order to get rid
of the ifdefery. No functional changes intended, this is
just a cosmetic change to organize the code better.

Given I2C is a tristate symbol, a hidden boolean symbol
is introduced, to make the conditional build easier.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 7c795df5 15-Aug-2019 Ezequiel Garcia <ezequiel@collabora.com>

media: v4l2-core: move spi helpers out of v4l2-common.c

Separate the spi helpers to v4l2-spi.c, in order to get rid
of the ifdefery. No functional changes intended, this is
just a cosmetic change to organize the code better.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# ff35213f 15-Aug-2019 Ezequiel Garcia <ezequiel@collabora.com>

media: v4l2-core: Module re-organization

videodev.ko and v4l2-common.ko driver are built under
the same conditions. Therefore, it doesn't make much sense
to split them in two different modules.

Splitting v4l2-common to its own driver was done many years ago:

commit a9254475bbfbed5f0596d952c6a3c9806e19dd0b
Author: Mauro Carvalho Chehab <mchehab@infradead.org>
Date: Tue Jan 29 18:32:35 2008 -0300

V4L/DVB (7115): Fix bug #9833: regression when compiling V4L without I2C

Back then, the subsystem organization was different and the module split
was needed. However, with the current organization, there is no issue
compiling V4L2 with I2C as y/m/n.

This commit makes v4l2-common part of our V4L2 core driver (videodev.ko).

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 079a649c 26-Jul-2019 Hans Verkuil <hverkuil-cisco@xs4all.nl>

media: v4l2-common: add support for new RGB32 pixelformats

Four new variants of RGB32 were added. Add support for them to
the v4l2_format_info() function.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 32cddf9c 28-May-2019 Boris Brezillon <boris.brezillon@collabora.com>

media: v4l2-common: Add an helper to apply frmsize constraints

The rockchip VPU driver is open-coding this logic which seems pretty
generic. Let's provide an helper to apply the min/max and alignment
constraints on width/height.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# ce57a82f 28-May-2019 Boris Brezillon <boris.brezillon@collabora.com>

media: v4l2-common: Fix v4l2_fill_pixfmt[_mp]() prototypes

Width/height and 4CC formats are expressed using u32 types everywhere,
let's fix the v4l2_fill_pixfmt[_mp]() prototypes to do the same.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 7371efe1 22-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 84

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version author [bill] [dirks]
[bill]@[thedirks] [org] [based] [on] [code] [by] [alan] [cox]
[alan]@[cymru] [net] video capture interface for linux a generic
video device interface for the linux operating system using a set of
device structures vectors for low level operations this program is
free software you can redistribute it and or modify it under the
terms of the gnu general public license as published by the free
software foundation either version 2 of the license or at your
option any later version

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 1 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Armijn Hemel <armijn@tjaldur.nl>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190520075211.410073327@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d82b921a 06-Mar-2019 Helen Fornazier <helen.koike@collabora.com>

media: v4l2-common: add bayer formats in v4l2_format_info

Add bayer format information in struct v4l2_format_info table.

Signed-off-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# f44b969a 28-Mar-2019 Ezequiel Garcia <ezequiel@collabora.com>

media: Introduce helpers to fill pixel format structs

Add two new API helpers, v4l2_fill_pixfmt and v4l2_fill_pixfmt_mp,
to be used by drivers to calculate plane sizes and bytes per lines.

Note that driver-specific padding and alignment are not
taken into account, and must be done by drivers using this API.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 276c1f06 21-Jan-2019 Hans Verkuil <hverkuil-cisco@xs4all.nl>

media: v4l2-common: drop v4l2_get_timestamp

This function is no longer used, so drop it.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 06582930 29-Aug-2018 Sakari Ailus <sakari.ailus@linux.intel.com>

media: v4l: subdev: Add a function to set an I²C sub-device's name

v4l2_i2c_subdev_set_name() can be used to assign a name to a sub-device.
This way uniform names can be formed easily without having to resort to
things such as snprintf in drivers.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 447d6685 01-Aug-2018 Philippe De Muyter <phdm@macqel.be>

media: v4l2-common: v4l2_spi_subdev_init : generate unique name

While v4l2_i2c_subdev_init does give a unique name to the subdev, matching
the one appearing in dmesg for messages generated by dev_info and friends
(e.g. imx185 30-0010), v4l2_spi_subdev_init does a poor job, copying only
the driver name, but not the dev_name(), yielding e.g. "imx185", but
missing the "spi1.1" part, and not generating a unique name.

Fix that.

Signed-off-by: Philippe De Muyter <phdm@macqel.be>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# c0decac1 10-Sep-2018 Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

media: use strscpy() instead of strlcpy()

The implementation of strscpy() is more robust and safer.

That's now the recommended way to copy NUL terminated strings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 3c91d24f 08-Feb-2018 Sakari Ailus <sakari.ailus@linux.intel.com>

media: v4l: common: Remove v4l2_find_nearest_format

v4l2_find_nearest_format is not useful for drivers in finding the best
matching format as it assumes a V4L2 specific struct. Drivers will use
v4l2_find_nearest_size instead.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 95ce9c28 23-Feb-2018 Sakari Ailus <sakari.ailus@linux.intel.com>

media: v4l: common: Add a function to obtain best size from a list

Add a function (as well as a helper macro) to obtain the best size in a
list of device specific sizes. This helps writing drivers as well as
aligns interface behaviour across drivers.

The struct in which this information is contained in is typically specific
to the driver, therefore the existing function v4l2_find_nearest_format()
does not address the need.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 672de9a7 22-Jan-2018 Hans Verkuil <hans.verkuil@cisco.com>

media: v4l2-common: create v4l2_g/s_parm_cap helpers

Create helpers to handle VIDIOC_G/S_PARM by querying the
g/s_frame_interval v4l2_subdev ops.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 76a59fe7 22-Sep-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

media: v4l2-common.h: document helper functions

There are several helper functions that aren't documented.

Document them.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 0545629e 22-Sep-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

media: v4l2-common: get rid of struct v4l2_discrete_probe

This struct is there just two store two arguments of
v4l2_find_nearest_format(). The other two arguments are passed
as parameter.

IMHO, there isn't much sense on doing that, and that will just
add one more struct to document ;)

So, let's get rid of the struct, passing the parameters directly.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 7c0f6ba6 24-Dec-2016 Linus Torvalds <torvalds@linux-foundation.org>

Replace <asm/uaccess.h> with <linux/uaccess.h> globally

This was entirely automated, using the script by Al:

PATT='^[[:blank:]]*#[[:blank:]]*include[[:blank:]]*<asm/uaccess.h>'
sed -i -e "s!$PATT!#include <linux/uaccess.h>!" \
$(git grep -l "$PATT"|grep -v ^include/linux/uaccess.h)

to do the replacement at the end of the merge window.

Requested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# fe094dad 19-Jul-2016 Markus Elfring <elfring@users.sourceforge.net>

[media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device"

The spi_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 4daee779 23-Nov-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2-common: move v4l2_ctrl_check to cx2341x

The v4l2_ctrl_check() helper function is now only used in cx2341x.
Move it there and make it static.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 4ed0d6a9 23-Nov-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2-common: remove unused helper functions

Several control helper functions are no longer needed since most drivers
are now converted to the control framework. So we can delete them.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 3bacc10c 15-Sep-2014 Maciej Matraszek <m.matraszek@samsung.com>

[media] v4l2-common: fix overflow in v4l_bound_align_image()

Fix clamp_align() used in v4l_bound_align_image() to prevent overflow
when passed large value like UINT32_MAX.

In the current implementation:
clamp_align(UINT32_MAX, 8, 8192, 3)

returns 8, because in line:

x = (x + (1 << (align - 1))) & mask;

x overflows to (-1 + 4) & 0x7 = 3, while expected value is 8192.

v4l_bound_align_image() is heavily used in VIDIOC_S_FMT and
VIDIOC_SUBDEV_S_FMT ioctls handlers, and documentation of the latter
explicitly states that:

"The modified format should be as close as possible to the original
request."
-- http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-subdev-g-fmt.html

Thus one would expect, that passing UINT32_MAX as format width and
height will result in setting maximum possible resolution for the
device. Particularly, when the driver doesn't support
VIDIOC_ENUM_FRAMESIZES ioctl, which is common in the codebase.

Fixes changeset: b0d3159be9a3

Signed-off-by: Maciej Matraszek <m.matraszek@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>


# 0ba2aeb6 16-Apr-2014 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2-ctrls: increase internal min/max/step/def to 64 bit

While VIDIOC_QUERYCTRL is limited to 32 bit min/max/step/def values
for controls, the upcoming VIDIOC_QUERY_EXT_CTRL isn't. So increase
the internal representation to 64 bits in preparation.

Because of these changes the msi3101 driver has been modified slightly
to fix a formatting issue (%d becomes %lld), vivi had to be modified
as well to cope with the new 64-bit min/max values and the PIXEL_RATE
control in a few sensor drivers required proper min/max/def values.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# f9d32f25 29-Sep-2013 Lars-Peter Clausen <lars@metafoo.de>

media: core: Don't use i2c_client->driver

The 'driver' field of the i2c_client struct is redundant and is going to be
removed. The results of the expressions 'client->driver.driver->field' and
'client->dev.driver->field' are identical, so replace all occurrences of the
former with the later.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 25764158 29-Jul-2013 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2: move dv-timings related code to v4l2-dv-timings.c

v4l2-common.c contained a bunch of dv-timings related functions.
Move that to the new v4l2-dv-timings.c which is a more appropriate
place for them.
There aren't many drivers that do HDTV, so it is a good idea to separate
common code related to that into a module of its own.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>


# 668773b8 10-Jun-2013 Guennadi Liakhovetski <g.liakhovetski@gmx.de>

[media] V4L2: add a device pointer to struct v4l2_subdev

It is often useful to have simple means to get from a subdevice to the
underlying physical device. This patch adds such a pointer to struct
v4l2_subdev and sets it accordingly in the I2C and SPI cases.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# aee38734 26-May-2013 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2-common: remove unused v4l2_chip_match/ident_i2c_client functions

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 6ec19898 26-May-2013 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2: remove obsolete v4l2_chip_match_host()

This function is no longer needed since it is now the responsibility of the
v4l2 core to check if the DBG_G/S_REGISTER and DBG_G_CHIP_INFO ioctls are
called for the bridge driver or not.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 3eef2510 03-Apr-2013 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2: drop V4L2_CHIP_MATCH_SUBDEV_NAME

After using the new VIDIOC_DBG_G_CHIP_NAME ioctl I realized that the matching
by name possibility is useless. Just drop it and rename MATCH_SUBDEV_IDX to
just MATCH_SUBDEV.
The v4l2-dbg utility is much better placed to match by name by just enumerating
all bridge and subdev devices until chip_name.name matches.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 79b0c640 17-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2: add new VIDIOC_DBG_G_CHIP_NAME ioctl

Simplify the debugging ioctls by creating the VIDIOC_DBG_G_CHIP_NAME ioctl.
This will eventually replace VIDIOC_DBG_G_CHIP_IDENT. Chip matching is done
by the name or index of subdevices or an index to a bridge chip. Most of this
can all be done automatically, so most drivers just need to provide get/set
register ops.
In particular, it is now possible to get/set subdev registers without
requiring assistance of the bridge driver.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 9d5f4839 06-Mar-2013 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2-common: remove obsolete check for ' at the end of a driver name

During the transition to sub-devices several years ago non-subdev drivers
had a ' at the end of their driver name to tell them apart from already
converted drivers. This check was a left-over from that time and can be
removed.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 2d80647b 15-Feb-2013 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2-common: remove obsolete v4l_fill_dv_preset_info

It's no longer used, so it can now be removed.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# ffe4db06 19-Jan-2013 Peter Senna Tschudin <peter.senna@gmail.com>

[media] [V2,24/24] v4l2-core/v4l2-common.c: use IS_ENABLED() macro

replace:
#if defined(CONFIG_MEDIA_TUNER_TEA5761) || \
defined(CONFIG_MEDIA_TUNER_TEA5761_MODULE)
with:
#if IS_ENABLED(CONFIG_MEDIA_TUNER_TEA5761)
This change was made for: CONFIG_MEDIA_TUNER_TEA5761
Also replaced:
#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE))
with:
#if IS_ENABLED(CONFIG_I2C)

Reported-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# abd23295 15-Sep-2012 Sakari Ailus <sakari.ailus@linux.intel.com>

[media] v4l: Helper function for obtaining timestamps

v4l2_get_timestamp() produces a monotonic timestamp but unlike
ktime_get_ts(), it uses struct timeval instead of struct timespec, saving
the drivers the conversion job when getting timestamps for v4l2_buffer's
timestamp field.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 685a39bd 27-Oct-2012 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] v4l2-common: h_bp var is unused at v4l2_detect_gtf()

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 07ca4188 17-Sep-2012 Alan Cox <alan@linux.intel.com>

[media] v4l2: spi modalias is an array

We want to check the contents not the array itself versus NULL

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# c61bd6a0 10-Aug-2012 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2-common: add CVT and GTF detection functions

These two helper functions detect whether the analog video timings detected
by the video receiver match the VESA CVT or GTF standards.

They basically do the inverse of the CVT and GTF modeline calculations.

This patch also adds a helper function that will determine the aspect ratio
based on the provided EDID values. This aspect ratio can be given to the GTF
helper function.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# c2a667fa 10-Aug-2012 Hans Verkuil <hans.verkuil@cisco.com>

[media] v4l2-common: add v4l_match_dv_timings

Add the v4l_match_dv_timings function that can be used to compare two
v4l2_dv_timings structs.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# 5bc3cb74 14-Jun-2012 Mauro Carvalho Chehab <mchehab@kernel.org>

[media] v4l: move v4l2 core into a separate directory

Currently, the v4l2 core is mixed together with other non-core drivers.
Move them into a separate directory.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>