Vikash Garodia [Thu, 20 Feb 2025 17:20:11 +0000 (22:50 +0530)]
media: venus: hfi: add a check to handle OOB in sfr region
sfr->buf_size is in shared memory and can be modified by malicious user.
OOB write is possible when the size is made higher than actual sfr data
buffer. Cap the size to allocated size for such cases.
Vikash Garodia [Thu, 20 Feb 2025 17:20:10 +0000 (22:50 +0530)]
media: venus: hfi: add check to handle incorrect queue size
qsize represents size of shared queued between driver and video
firmware. Firmware can modify this value to an invalid large value. In
such situation, empty_space will be bigger than the space actually
available. Since new_wr_idx is not checked, so the following code will
result in an OOB write.
...
qsize = qhdr->q_size
words_count denotes the number of words in total payload, while data
points to payload of various property within it. When words_count
reaches last word, data can access memory beyond the total payload. This
can lead to OOB access. With this patch, the utility api for handling
individual properties now returns the size of data consumed. Accordingly
remaining bytes are calculated before parsing the payload, thereby
eliminates the OOB access possibilities.
Vikash Garodia [Thu, 20 Feb 2025 17:20:08 +0000 (22:50 +0530)]
media: venus: hfi_parser: add check to avoid out of bound access
There is a possibility that init_codecs is invoked multiple times during
manipulated payload from video firmware. In such case, if codecs_count
can get incremented to value more than MAX_CODEC_NUM, there can be OOB
access. Reset the count so that it always starts from beginning.
Nicolas Dufresne [Tue, 10 Dec 2024 21:02:53 +0000 (16:02 -0500)]
media: visl: Fix ERANGE error when setting enum controls
The visl driver supports both frame and slice mode, with and without a
start-code. But, the range and default for these enum controls was not
set, which currently limits the decoder to enums with a value of 0. Fix
this by setting the decoder mode and start code controls for both the
H.264 and HEVC codecs.
Fixes: 0c078e310b6d ("media: visl: add virtual stateless decoder driver") Cc: stable@vger.kernel.org Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Ricardo Ribalda [Mon, 24 Feb 2025 07:03:55 +0000 (07:03 +0000)]
media: nuvoton: Fix reference handling of ece_pdev
When we obtain a reference to of a platform_device, we need to release
it via put_device.
Found by cocci:
./platform/nuvoton/npcm-video.c:1677:3-9: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function.
./platform/nuvoton/npcm-video.c:1684:3-9: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function.
./platform/nuvoton/npcm-video.c:1690:3-9: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function.
./platform/nuvoton/npcm-video.c:1694:1-7: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function.
Instead of manually calling put_device, use the __free macros.
Cc: stable@vger.kernel.org Fixes: 46c15a4ff1f4 ("media: nuvoton: Add driver for NPCM video capture and encoding engine") Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Niklas Söderlund [Fri, 21 Feb 2025 23:09:07 +0000 (00:09 +0100)]
media: adv7180: Disable test-pattern control on adv7180
The register that enables selecting a test-pattern to be outputted in
free-run mode (FREE_RUN_PAT_SEL[2:0]) is only available on adv7280 based
devices, not the adv7180 based ones.
Add a flag to mark devices that are capable of generating test-patterns,
and those that are not. And only register the control on supported
devices.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Dr. David Alan Gilbert [Thu, 20 Feb 2025 16:55:16 +0000 (16:55 +0000)]
media: cx23885: Remove unused netup_eeprom_write
netup_eeprom_write() was added in 2009 by
commit b45c0551f94d ("V4L/DVB (10797): Add EEPROM code for NetUP Dual
DVB-S2 CI card.")
but has remained unused.
Remove it.
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Matthias Fend [Tue, 21 Jan 2025 09:56:55 +0000 (10:56 +0100)]
media: tc358746: fix locking issue
In tc358746_link_validate() an attempt is made to get the state lock of the
subdev, but since this is already held by the calling function
v4l2_subdev_link_validate(), this leads to a deadlock.
Another problem is that this function queries the link frequency of the
source device. Since some image sensors use the lock of the v4l2 control
handler as a state lock, which is already held at this point, a deadlock
can also occur here.
Move the calculation of the FIFO size from tc358746_link_validate() to
tc358746_apply_misc_config() to avoid the deadlocks mentioned.
Signed-off-by: Matthias Fend <matthias.fend@emfend.at> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Matthias Fend [Tue, 7 Jan 2025 16:07:01 +0000 (17:07 +0100)]
media: tc358746: improve calculation of the D-PHY timing registers
When calculating D-PHY registers, using data rates that are not multiples
of 16 can lead to precision loss in division operations. This can result in
register values that produce timing violations against the MIPI standard.
An example:
cfg->hs_clk_rate = 294MHz
hf_clk = 18
If the desired value in cfg->init is 100us, which is the minimum allowed
value, then the LINEINITCNT register is calculated as 1799. But since the
actual clock is 18.375MHz instead of 18MHz, this setting results in a time
that is shorter than 100us and thus violates the standard. The correct
value for LINEINITCNT would be 1837.
Improve the precision of calculations by using Hz instead of MHz as unit.
Signed-off-by: Matthias Fend <matthias.fend@emfend.at> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Matthias Fend [Tue, 7 Jan 2025 16:07:00 +0000 (17:07 +0100)]
media: tc358746: add support for 8/10/12/14-bit RAW Bayer formats
The TC358746 supports RAW formats with 8, 10, 12, and 14-bit depths. Since
pixel data is transported transparently without modifying the pixel
arrangement, all Bayer patterns (RGGB, BGGR, GRBG, GBRG) are supported.
Signed-off-by: Matthias Fend <matthias.fend@emfend.at> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Joe Hattori [Thu, 5 Dec 2024 02:06:21 +0000 (11:06 +0900)]
media: platform: allgro-dvt: unregister v4l2_device on the error path
In allegro_probe(), the v4l2 device is not unregistered in the error
path, which results in a memory leak. Fix it by calling
v4l2_device_unregister() before returning error.
Fixes: d74d4e2359ec ("media: allegro: move driver out of staging") Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> Reviewed-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Benjamin Gaignard [Mon, 20 Jan 2025 08:13:42 +0000 (09:13 +0100)]
media: verisilicon: VP9: Fix typo
Change headres_size to headers_size.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Benjamin Gaignard [Mon, 20 Jan 2025 08:10:52 +0000 (09:10 +0100)]
media: verisilicon: HEVC: Initialize start_bit field
The HEVC driver needs to set the start_bit field explicitly to avoid
causing corrupted frames when the VP9 decoder is used in parallel. The
reason for this problem is that the VP9 and the HEVC decoder share this
register.
Fixes: cb5dd5a0fa51 ("media: hantro: Introduce G2/HEVC decoder") Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
'struct i2c_algorithm' are not modified in these drivers.
Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.
More over, dvb_usb_device_properties->i2c_algo seems to only be copied in
i2c_adapter->algo, which is already a "const struct i2c_algorithm".
This is done in dvb_usbv2_i2c_init()
On a x86_64, with allmodconfig, as an example:
Before:
======
text data bss dec hex filename
35366 5832 36 41234 a112 drivers/media/usb/dvb-usb-v2/af9015.o
After:
=====
text data bss dec hex filename
35430 5768 36 41234 a112 drivers/media/usb/dvb-usb-v2/af9015.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
'struct i2c_algorithm' are not modified in these drivers.
Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.
More over, dvb_usb_device_properties->i2c_algo seems to only be copied in
i2c_adapter->algo, which is already a "const struct i2c_algorithm".
This is done in dvb_usb_i2c_init()
On a x86_64, with allmodconfig, as an example:
Before:
======
text data bss dec hex filename
30571 5916 36 36523 8eab drivers/media/usb/dvb-usb/af9005.o
After:
=====
text data bss dec hex filename
30667 5852 36 36555 8ecb drivers/media/usb/dvb-usb/af9005.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
'struct i2c_algorithm' is not modified in this driver.
Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.
To do so, the prototype of i2c_adapter_init() has to be updated as well.
On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
17213 932 20 18165 46f5 drivers/media/dvb-frontends/dibx000_common.o
After:
=====
text data bss dec hex filename
17490 660 20 18170 46fa drivers/media/dvb-frontends/dibx000_common.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Ricardo Ribalda [Mon, 2 Dec 2024 15:47:15 +0000 (15:47 +0000)]
media: cx231xx: Convert enum into a define
The code is running arithmetics with the enum, which when not done with
care makes the compiler a bit nervous.
Because those enums are only used as defines (no argument or variable
from that enumeration type), convert it into a define and move on.
It is required to build with llvm 9 without these warnings:
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:673:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:680:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:687:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:702:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:709:21: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:718:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion]
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:727:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion]
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:737:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion]
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:749:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion]
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
[hverkuil: fix a tiny typo in the commit log]
Matthias Schwarzott [Tue, 31 Dec 2024 09:37:25 +0000 (10:37 +0100)]
media: cx23885: add simple suspend/resume
After suspend-to-memory or suspend-to-disk, additional chips are no longer
reachable via i2c. Trying to tune to DVB-C on a cx23885 based
Hauppauge WinTV-HVR-4400-HD:
si2165 8-0064: could not set chip_mode
tda18271: performing RF tracking filter calibration
This patch implements the simplest possible suspend/resume that is
enough to tune to dvb-c channel after resume.
Afterwards dmesg looks like this:
Xiaolei Wang [Sat, 21 Dec 2024 03:14:55 +0000 (11:14 +0800)]
media: coda: Add system resume interface
When the system goes into sleep mode, the dependent
power will be turned off, so when the system resumes,
coda_hw_init() needs to be called, otherwise it will
get 'CODA PIC_RUN timeout' after resuming.
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Zhang Heng [Fri, 17 Jan 2025 09:55:30 +0000 (17:55 +0800)]
media: pwc: remove useless header files
It was originally intended to introduce simple_strtol,
but since commit a081c3400ff2 ("[media] pwc: Remove dev_hint
module parameter"), that simple_strtol has been removed,
so in order to prevent disputes, the header file should be removed.
Signed-off-by: Zhang Heng <zhangheng@kylinos.cn> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
[hverkuil: fixed small typos in commit log]
Niklas Söderlund [Tue, 21 Jan 2025 20:44:00 +0000 (21:44 +0100)]
media: i2c: adv748x: Fix test pattern selection mask
The mask to select the test-pattern in register ADV748X_SDP_FRP is
incorrect, it's the lower 3 bits which controls the pattern. The
GENMASK() macro is used incorrectly and the generated mask is 0x0e
instead of 0x07.
The result is that not all test patterns are selectable, and that in
some cases the wrong test pattern is activated. Fix this by correcting
the GENMASK().
Martin Tůma [Mon, 27 Jan 2025 15:59:56 +0000 (16:59 +0100)]
media: mgb4: Added support for additional GMSL modules variants
Added support for GMSL modules variants 3 and 4. Variant 3 is the same as
variant 2 from the driver's point of view. Variant 4 has "hardwired" daisy
chain loopback outputs and thus missing the v4l2 outputs.
Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Chandra Pratap [Tue, 28 Jan 2025 08:50:12 +0000 (14:20 +0530)]
Documentation: media: fix spelling error in the HDMI CEC documentation
Correct the erroneous spelling of 'responsible' in
Documentation/admin-guide/media/cec.rst. This fixes all errors
pointed out by codespell in the file.
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Jiasheng Jiang [Tue, 18 Feb 2025 18:58:09 +0000 (18:58 +0000)]
media: mediatek: vcodec: Fix a resource leak related to the scp device in FW initialization
On Mediatek devices with a system companion processor (SCP) the mtk_scp
structure has to be removed explicitly to avoid a resource leak.
Free the structure in case the allocation of the firmware structure fails
during the firmware initialization.
Fixes: 53dbe0850444 ("media: mtk-vcodec: potential null pointer deference in SCP") Cc: stable@vger.kernel.org Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Niklas Söderlund [Wed, 12 Feb 2025 16:50:53 +0000 (17:50 +0100)]
media: uapi: rkisp1-config: Fix typo in extensible params example
The define used for the version in the example diagram does not match what
is defined in enum rksip1_ext_param_buffer_version, nor the description
above it. Correct the typo to make it clear which define to use.
The MIPID02 can use up to 2 data lanes which leads to having a maximum
item number of 3 for the lane-polarities since this also contains the
clock lane.
CC: stable@vger.kernel.org Fixes: c2741cbe7f8a ("dt-bindings: media: st,stmipid02: Convert the text bindings to YAML") Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Acked-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Hans Verkuil [Tue, 28 Jan 2025 15:03:39 +0000 (16:03 +0100)]
media: platform: rpi1-cfe: drop vb2_ops_wait_prepare/finish
Since commit 88785982a19d ("media: vb2: use lock if wait_prepare/finish
are NULL") it is no longer needed to set the wait_prepare/finish
vb2_ops callbacks as long as the lock field in vb2_queue is set.
Since the vb2_ops_wait_prepare/finish callbacks already rely on that field,
we can safely drop these callbacks.
This simplifies the code and this is a step towards the goal of deleting
these callbacks.
This new function determines how many blocks the EDID has.
Traditionally the number of extension blocks is read from
the EDID at offset 126, but this can be overridden by the
HDMI Forum EDID Extension Override Data Block. So check
that as well in this helper.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Hans de Goede [Tue, 5 Nov 2024 20:36:58 +0000 (21:36 +0100)]
media: dw9719: Add DW9761 support
Add support for the DW9761 VCM controller, which is very similar to
the DW9719.
The new support is based on
drivers/external_drivers/camera/drivers/media/i2c/micam/dw9761.c
from the Xiaomi kernel sources for the Mi Pad 2.
The DW9761 support has been tested on a Xiaomi Mi Pad 2 tablet and
DW9719 support has been tested (to avoid regressions) on a Microsoft
Surface Go tablet.
Link: https://github.com/MiCode/Xiaomi_Kernel_OpenSource/ Signed-off-by: Hans de Goede <hdegoede@redhat.com> Tested-by: André Apitzsch <git@apitzsch.eu> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Vladimir Zapolskiy [Wed, 25 Dec 2024 20:57:48 +0000 (22:57 +0200)]
media: qcom: camss: switch CSID to defined MIPI CSI data type IDs
Remove redefined image data type IDs taken directly from the MIPI CSI-2
specification. Non-functional change.
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Jai Luthra [Tue, 4 Feb 2025 07:04:40 +0000 (12:34 +0530)]
media: i2c: imx219: Scale the pixel rate for analog binning
When the analog binning mode is used for high framerate operation, the
pixel rate is effectively doubled. Account for this when setting up the
pixel clock rate, and applying the vblank and exposure controls.
The previous logic only used analog binning for RAW8, but normal binning
limits the framerate on RAW10 480p [1]. So with this patch we switch to
using special binning (with 2x pixel rate) wherever possible.
Jai Luthra [Tue, 4 Feb 2025 07:04:39 +0000 (12:34 +0530)]
media: i2c: imx219: Increase minimum LLP to fix blocky artefacts
The sensor's internal ADC supports a minimum line length of 3448 pixels,
which may be too small to use with analog binning, where ADC operates on
two lines together. Switch to a higher minimum line length of 3560
pixels to fix the blocky artefacts seen with analog binning [1].
To keep the same default framerate as before for all the modes, lower
the default fll value to compensate for the increase in llp.
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Dave Stevenson [Tue, 4 Feb 2025 07:04:38 +0000 (12:34 +0530)]
media: i2c: imx219: make HBLANK r/w to allow longer exposures
The HBLANK control was read-only, and always configured such that the
sensor line length register was 3448. This limited the maximum exposure
time that could be achieved to around 1.26 secs.
Make HBLANK read/write so that the line time can be extended, and
thereby allow longer exposures (and slower frame rates). Retain the
overall line length setting when changing modes rather than resetting it
to a default.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Jai Luthra [Tue, 4 Feb 2025 07:04:37 +0000 (12:34 +0530)]
media: i2c: imx219: Rename VTS to FRM_LENGTH
The IMX219 datasheet refers to the vertical length + blanking as
FRM_LENGTH instead of VTS.
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
David Plowman [Tue, 4 Feb 2025 07:04:36 +0000 (12:34 +0530)]
media: i2c: imx219: Correct the minimum vblanking value
The datasheet for this sensor documents the minimum vblanking as being
32 lines. It does fix some problems with occasional black lines at the
bottom of images (tested on Raspberry Pi).
Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Dave Stevenson [Thu, 23 Jan 2025 15:37:49 +0000 (15:37 +0000)]
media: imx219: Adjust PLL settings based on the number of MIPI lanes
Commit ceddfd4493b3 ("media: i2c: imx219: Support four-lane operation")
added support for device tree to allow configuration of the sensor to
use 4 lanes with a link frequency of 363MHz, and amended the advertised
pixel rate to 280.8MPix/s.
However it didn't change any of the PLL settings, so actually it would
have been running overclocked in the MIPI block, and with the frame
rate and exposure calculations being wrong as the pixel rate was
unchanged.
The pixel rate and link frequency advertised were taken from the "Clock
Setting Example" section of the datasheet. However those are based on an
external clock of 12MHz, and are unachievable with a clock of 24MHz - it
seems PREPLLCLK_VT_DIV and PREPLLCK_OP_DIV can ONLY be set via the
automatic configuration documented in "9-1-2 EXCK_FREQ setting depend on
INCK frequency", not by writing the registers.
The closest we can get with a 24MHz clock is 281.6MPix/s and 364MHz.
Dropping all support for the 363MHz link frequency would cause problems
for existing users, so allow it, but log a warning that the requested
value is being changed to the supported one.
Fixes: ceddfd4493b3 ("media: i2c: imx219: Support four-lane operation") Cc: stable@vger.kernel.org Co-developed-by: Peyton Howe <peyton.howe@bellsouth.net> Signed-off-by: Peyton Howe <peyton.howe@bellsouth.net> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Dave Stevenson [Wed, 29 Jan 2025 15:03:51 +0000 (15:03 +0000)]
media: i2c: imx415: Link frequencies are not exclusive to num lanes
The link frequencies are equally valid in 2 or 4 lane modes, but
they change the hmax_min value for the mode as the MIPI block
has to have sufficient time to send the pixel data for each line.
Remove the association with number of lanes, and add hmax_min
configuration for both lane options.
Reviewed-by: Michael Riesch <michael.riesch@wolfvision.net> Reviewed-by: Gerald Loacker <gerald.loacker@wolfvision.net> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Dave Stevenson [Wed, 29 Jan 2025 15:03:50 +0000 (15:03 +0000)]
media: i2c: imx415: Make HBLANK controllable and in consistent units
The control of HMAX documented in the datasheet is consistent
with being in terms of a scaled INCK, being always 72MHz or
74.25MHz. It is NOT link frequency dependent, but the minimum
value for HMAX is dictated by the link frequency.
If PIXEL_RATE is defined as being 12 times the 72 or 74.25MHz,
and all values are scaled down again when writing HMAX, then
the numbers all work out regardless of INCK or link frequency.
Retain an hmax_min (set to the same value as the previous fixed
hmax register value) to set as the default value to avoid changing
the behaviour for existing users.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Michael Riesch <michael.riesch@wolfvision.net> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Dave Stevenson [Wed, 29 Jan 2025 15:03:49 +0000 (15:03 +0000)]
media: i2c: imx415: Add read/write control of VBLANK
This also requires that the ranges for the exposure control
are updated.
Reviewed-by: Michael Riesch <michael.riesch@wolfvision.net> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Mon, 16 Dec 2024 09:25:31 +0000 (11:25 +0200)]
media: v4l: Convert the users of v4l2_get_link_freq to call it on a pad
Call v4l2_get_link_freq() on a pad, instead of a control handler. This way
we can soon convert v4l2_get_link_freq() to be callable only on a pad and
remove the compatibility code.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Naushir Patuck <naush@raspberrypi.com> # rp1-cfe Acked-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com> # st-mipid02 Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Thu, 16 May 2024 12:25:39 +0000 (15:25 +0300)]
media: ivsc: csi: Obtain link frequency from the media pad
Support the use of the media pad for obtaining the link frequency.
Similarly, call the v4l2_get_link_freq() on the media pad, not on the
remote's control handler.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Mon, 29 Apr 2024 09:19:40 +0000 (12:19 +0300)]
media: intel/ipu6: Obtain link frequency from the remote subdev pad
Obtain the link frequency from the sub-device's pad instead of a control
handler. This allows obtaining it using the get_mbus_config() sub-device
pad op which is the only method supported by the IVSC driver.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Mon, 16 Dec 2024 08:48:49 +0000 (10:48 +0200)]
media: v4l: Memset argument to 0 before calling get_mbus_config pad op
Memset the config argument to get_mbus_config V4L2 sub-device pad
operation to zero before calling the operation. This ensures the callers
don't need to bother with it nor the implementations need to set all
fields that may not be relevant to them.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Mon, 16 Dec 2024 08:26:22 +0000 (10:26 +0200)]
media: Documentation: Receiver drivers should call v4l2_get_link_freq()
Document that receiver drivers should call v4l2_get_link_freq() to obtain
the link frequency.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Mon, 16 Dec 2024 08:10:40 +0000 (10:10 +0200)]
media: Documentation: tx-rx: Move transmitter control out of CSI-2 part
The subsection on stopping the transmitter belongs to the generic part and
is not specific to CSI-2. Move it out of the CSI-2 section.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Thu, 16 May 2024 12:25:38 +0000 (15:25 +0300)]
media: Documentation: Update link frequency driver documentation
Add the get_mbus_config() as the means for conveying the link frequency
towards the receiver drivers.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Mon, 29 Apr 2024 08:44:22 +0000 (11:44 +0300)]
media: v4l: Support obtaining link frequency via get_mbus_config
Add link_freq field to struct v4l2_mbus_config in order to pass the link
frequency to the receiving sub-device.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Mon, 29 Apr 2024 08:38:23 +0000 (11:38 +0300)]
media: v4l: Support passing media pad argument to v4l2_get_link_freq()
v4l2_get_link_freq() accepts a V4L2 control handler for now, but it needs
to take struct media_pad argument in order to obtain the link frequency
using get_mbus_config() pad op. Prepare for this by allowing struct
media_pad as well.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Hans Verkuil [Tue, 28 Jan 2025 15:02:53 +0000 (16:02 +0100)]
media: pci: ipu6: drop vb2_ops_wait_prepare/finish
Since commit 88785982a19d ("media: vb2: use lock if wait_prepare/finish
are NULL") it is no longer needed to set the wait_prepare/finish
vb2_ops callbacks as long as the lock field in vb2_queue is set.
Since the vb2_ops_wait_prepare/finish callbacks already rely on that field,
we can safely drop these callbacks.
This simplifies the code and this is a step towards the goal of deleting
these callbacks.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Fri, 17 Jan 2025 14:04:02 +0000 (16:04 +0200)]
media: i2c: ov7251: Introduce 1 ms delay between regulators and en GPIO
Lift the xshutdown (enable) GPIO 1 ms after enabling the regulators, as
required by the sensor's power-up sequence.
Fixes: d30bb512da3d ("media: Add a driver for the ov7251 camera sensor") Cc: stable@vger.kernel.org Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Fri, 17 Jan 2025 13:38:13 +0000 (15:38 +0200)]
media: i2c: ov7251: Set enable GPIO low in probe
Set the enable GPIO low when acquiring it.
Fixes: d30bb512da3d ("media: Add a driver for the ov7251 camera sensor") Cc: stable@vger.kernel.org Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Fri, 10 Jan 2025 12:55:59 +0000 (14:55 +0200)]
media: i2c: imx319: Rectify runtime PM handling probe and remove
Idle the device only after the async sub-device has been successfully
registered. In error handling, set the device's runtime PM status to
suspended only if it has been set to active previously in probe.
Also set the device's runtime PM status to suspended in remove only if it
wasn't so already.
Fixes: 8a89dc62f28c ("media: add imx319 camera sensor driver") Cc: stable@vger.kernel.org # for >= v6.12 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Fri, 10 Jan 2025 12:53:20 +0000 (14:53 +0200)]
media: i2c: imx219: Rectify runtime PM handling in probe and remove
Set the device's runtime PM status and enable runtime PM before
registering the async sub-device. This is needed to avoid the case where
the device is runtime PM resumed while runtime PM has not been enabled
yet.
Also set the device's runtime PM status to suspended in remove only if it
wasn't so already.
Fixes: 1283b3b8f82b ("media: i2c: Add driver for Sony IMX219 sensor") Cc: stable@vger.kernel.org # for >= v6.6 Reviewed-by: Bingbu Cao <bingbu.cao@intel.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Alain Volmat [Mon, 13 Jan 2025 08:57:59 +0000 (09:57 +0100)]
media: stm32: dcmipp: add has_csi2 & needs_mclk in match data
Introduce two variable has_csi and has_mclk within the
match data of the driver in order to know, depending on
the compatible if CSI-2 interface is available and if
the mclk clk should be retrieved.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
The endpoint is already retrieved at the beginning of the function
stm32_csi_parse_dt hence keep the endpoint pointer until the end
instead of getting a new one.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Alain Volmat [Mon, 13 Jan 2025 08:57:54 +0000 (09:57 +0100)]
media: stm32: csi: register subdev only at end of probe
Call v4l2_async_register_subdev only whenever all initialization
are completed at the end of the probe function.
Remove as well useless err_free_priv label by returning directly
upon error.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Alain Volmat [Mon, 13 Jan 2025 08:57:53 +0000 (09:57 +0100)]
media: stm32: csi: add missing pm_runtime_put on error
Within the stm32_csi_start function, pm_runtime_put should
be called upon error following pm_runtime_get_sync.
Rework the function error handling by putting a label in
order to have common error handling for all calls requiring
pm_runtime_put.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Alain Volmat [Mon, 13 Jan 2025 08:57:52 +0000 (09:57 +0100)]
dt-bindings: media: clarify stm32 csi & simplify example
Clarify the description of the stm32 CSI by mentioning CSI-2 and D-PHY.
Remove the bus-type property from the example since this CSI has a D-PHY,
which is the only bus-type option, making this property redundant.
Acked-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Fri, 10 Jan 2025 07:36:45 +0000 (09:36 +0200)]
media: i2c: ov2740: Small cleanups
Small cleanups for the driver, namely removal of OV2740_NUM_SUPPLIES
macro, use of unsigned int for a loop and printing the missing "0x" for a
hexadecimal number.
Co-developed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Sakari Ailus [Fri, 10 Jan 2025 07:33:33 +0000 (09:33 +0200)]
media: i2c: ov2740: Free control handler on error path
The control handler wasn't freed if v4l2_fwnode_device_parse() failed. Do
that now.
Co-developed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
André Apitzsch [Fri, 20 Dec 2024 13:26:12 +0000 (14:26 +0100)]
media: i2c: imx214: Fix link frequency validation
The driver defines IMX214_DEFAULT_LINK_FREQ 480000000, and then
IMX214_DEFAULT_PIXEL_RATE ((IMX214_DEFAULT_LINK_FREQ * 8LL) / 10),
which works out as 384MPix/s. (The 8 is 4 lanes and DDR.)
Parsing the PLL registers with the defined 24MHz input. We're in single
PLL mode, so MIPI frequency is directly linked to pixel rate. VTCK ends
up being 1200MHz, and VTPXCK and OPPXCK both are 120MHz. Section 5.3
"Frame rate calculation formula" says "Pixel rate
[pixels/s] = VTPXCK [MHz] * 4", so 120 * 4 = 480MPix/s, which basically
agrees with my number above.
3.1.4. MIPI global timing setting says "Output bitrate = OPPXCK * reg
0x113[7:0]", so 120MHz * 10, or 1200Mbit/s. That would be a link
frequency of 600MHz due to DDR.
That also matches to 480MPix/s * 10bpp / 4 lanes / 2 for DDR.
Keep the previous link frequency for backward compatibility.
Acked-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: André Apitzsch <git@apitzsch.eu> Fixes: 436190596241 ("media: imx214: Add imx214 camera sensor driver") Cc: stable@vger.kernel.org Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
André Apitzsch [Fri, 20 Dec 2024 13:26:08 +0000 (14:26 +0100)]
media: i2c: imx214: Add analogue/digital gain control
The imx214 sensor supports analogue gain up to 8x and digital gain up to
16x. Implement the corresponding controls in the driver. Default gain
values are not modified by this patch.
Acked-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: André Apitzsch <git@apitzsch.eu> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
André Apitzsch [Fri, 20 Dec 2024 13:26:06 +0000 (14:26 +0100)]
media: i2c: imx214: Add vblank and hblank controls
Add vblank control to allow changing the framerate /
higher exposure values.
The vblank and hblank controls are needed for libcamera support.
While at it, fix the minimal exposure time according to the datasheet.
Signed-off-by: André Apitzsch <git@apitzsch.eu> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
André Apitzsch [Fri, 20 Dec 2024 13:26:04 +0000 (14:26 +0100)]
media: i2c: imx214: Drop IMX214_REG_EXPOSURE from mode reg arrays
The IMX214_REG_EXPOSURE is configured twice, once with a hardcoded value
in the mode_<res> registers arrays, and once via v4l2_ctrl_ops. The
latter is enough, drop the former.
Acked-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: André Apitzsch <git@apitzsch.eu> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
André Apitzsch [Fri, 20 Dec 2024 13:26:02 +0000 (14:26 +0100)]
media: i2c: imx214: Convert to CCI register access helpers
Use the new common CCI register access helpers to replace the private
register access helpers in the imx214 driver. This simplifies the driver
by reducing the amount of code.
Acked-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: André Apitzsch <git@apitzsch.eu> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
André Apitzsch [Fri, 20 Dec 2024 13:26:00 +0000 (14:26 +0100)]
media: i2c: imx214: Use subdev active state
Port the imx214 sensor driver to use the subdev active state.
Move all the format configuration to the subdevice state and simplify
the format handling, locking and initialization.
While at it, simplify imx214_start_streaming() by removing unneeded goto
statements and the corresponding error label.
Signed-off-by: André Apitzsch <git@apitzsch.eu> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Revert this "fix" as it's not really helpful but makes backporting a
proper fix harder.
Fixes: 9bc92332cc3f ("media: imx214: Fix the error handling in imx214_probe()") Cc: stable@vger.kernel.org # for >= v6.12 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
All ov08x40_check_hwcfg() error-exit paths already log a detailed reason,
logging a second generic "failed to check hwcfg" error is not useful, and
in case of the fwnode check failing with -EPROBE_DEFER this is outright
problematic flooding the log with:
[ 4.557059] ov08x40 i2c-OVTI08F4:00: failed to check hwcfg: -517
[ 4.559636] ov08x40 i2c-OVTI08F4:00: failed to check hwcfg: -517
etc.
messages.
The one exception to all ov08x40_check_hwcfg() error-exit paths already
logging an error is on v4l2_fwnode_endpoint_alloc_parse() errors.
Make ov08x40_check_hwcfg() log an error in that case too and drop
the duplicate "failed to check hwcfg: %d\n" error logging.
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>