linux-block.git
4 months agomedia: intel/ipu6: Don't print user-triggerable errors to kernel log
Sakari Ailus [Thu, 2 May 2024 15:21:30 +0000 (18:21 +0300)]
media: intel/ipu6: Don't print user-triggerable errors to kernel log

Use dev_dbg() for printing messages on user-triggerable conditions that
have no relation to driver or hardware issues.

Fixes: 3c1dfb5a69cf ("media: intel/ipu6: input system video nodes and buffer queues")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agoMerge tag 'media-fixes-unicam-20240510' of https://git.kernel.org/pub/scm/linux/kerne...
Hans Verkuil [Fri, 10 May 2024 07:53:11 +0000 (09:53 +0200)]
Merge tag 'media-fixes-unicam-20240510' of https://git./linux/kernel/git/pinchartl/linux into media_stage

bcm2835-unicam fixes for v6.10

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.linuxtv.org/project/linux-media/patch/20240509222123.GA21033@pendragon.ideasonboard.com/
4 months agomedia: bcm2835-unicam: Fix driver path in MAINTAINERS
Laurent Pinchart [Wed, 1 May 2024 11:54:39 +0000 (14:54 +0300)]
media: bcm2835-unicam: Fix driver path in MAINTAINERS

The MAINTAINERS file entry for the bcm2835-unicam driver incorrectly
references the non-existing drivers/media/platform/bcm2835/ path. Fix
it.

Fixes: 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface")
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Link: https://lore.kernel.org/r/20240501115439.9789-1-laurent.pinchart@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
4 months agomedia: bcm2835-unicam: Fix a NULL vs IS_ERR() check
Dan Carpenter [Wed, 8 May 2024 12:31:00 +0000 (15:31 +0300)]
media: bcm2835-unicam: Fix a NULL vs IS_ERR() check

The media_pad_remote_pad_unique() function returns error pointers, not
NULL.  Update the check accordingly.

Fixes: 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/fbbe7862-2820-44eb-81cb-7f33b99cca35@moroto.mountain
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
4 months agomedia: bcm2835-unicam: Do not print error when irq not found
Ricardo Ribalda [Mon, 6 May 2024 19:24:47 +0000 (19:24 +0000)]
media: bcm2835-unicam: Do not print error when irq not found

platform_get_irq() already prints an error for us.

Fix this cocci warning:
drivers/media/platform/broadcom/bcm2835-unicam.c:2664:2-9: line 2664 is redundant because platform_get_irq() already prints an error

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Link: https://lore.kernel.org/r/20240506-fix-broad-v2-2-e6a2a5c0d609@chromium.org
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
4 months agomedia: bcm2835-unicam: Do not replace IRQ retcode during probe
Ricardo Ribalda [Mon, 6 May 2024 19:24:46 +0000 (19:24 +0000)]
media: bcm2835-unicam: Do not replace IRQ retcode during probe

platform_get_irq() cannot return the value 0. It will either return a non-zero
irq or a errcode.

If a errcode is returned, we need to populate the error code upwards. It will
give a more accurate reason of why it failed to the caller, who might decide
to retry later.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20240506-fix-broad-v2-1-e6a2a5c0d609@chromium.org
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
4 months agomedia: bcm2835-unicam: Convert to platform remove callback returning void
Uwe Kleine-König [Mon, 6 May 2024 10:09:16 +0000 (12:09 +0200)]
media: bcm2835-unicam: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20240506100917.1544174-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
4 months agomedia: media: intel/ipu6: Fix spelling mistake "remappinp" -> "remapping"
Colin Ian King [Wed, 8 May 2024 08:17:12 +0000 (10:17 +0200)]
media: media: intel/ipu6: Fix spelling mistake "remappinp" -> "remapping"

There is a spelling mistake in a dev_err_probe message. Fix it.

Link: https://lore.kernel.org/linux-media/20240508081712.2868257-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: intel/ipu6: explicitly include vmalloc.h
Stephen Rothwell [Tue, 7 May 2024 12:35:28 +0000 (14:35 +0200)]
media: intel/ipu6: explicitly include vmalloc.h

linux/vmalloc.h needs to be included explicitly nowadays. Do it.

Link: https://lore.kernel.org/linux-media/20240507123528.932421-1-sakari.ailus@linux.intel.com
Fixes: 9163d83573e4 ("media: intel/ipu6: add IPU6 DMA mapping API and MMU table")
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: cec.h: Fix kerneldoc
Ricardo Ribalda [Fri, 3 May 2024 11:33:20 +0000 (11:33 +0000)]
media: cec.h: Fix kerneldoc

is_claiming_log_addrs documentation was missing.

fix this kernel-doc warning:
include/media/cec.h:296: warning: Function parameter or struct member 'is_claiming_log_addrs' not described in 'cec_adapter'

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: uvcvideo: Refactor iterators
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:42 +0000 (15:04 +0000)]
media: uvcvideo: Refactor iterators

Avoid using the iterators after the list_for_each() constructs.
This patch should be a NOP, but makes cocci, happier:

drivers/media/usb/uvc/uvc_ctrl.c:1861:44-50: ERROR: invalid reference to the index variable of the iterator on line 1850
drivers/media/usb/uvc/uvc_ctrl.c:2195:17-23: ERROR: invalid reference to the index variable of the iterator on line 2179

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: async: refactor v4l2_async_create_ancillary_links
Ricardo Ribalda [Mon, 15 Apr 2024 19:34:26 +0000 (19:34 +0000)]
media: v4l: async: refactor v4l2_async_create_ancillary_links

Return 0 without checking IS_ERR or PTR_ERR if CONFIG_MEDIA_CONTROLLER
is not enabled.

This makes cocci happier:

drivers/media/v4l2-core/v4l2-async.c:331:23-30: ERROR: PTR_ERR applied after initialization to constant on line 319

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: Don't re-allocate memory for firmware
Sakari Ailus [Thu, 2 May 2024 15:49:50 +0000 (16:49 +0100)]
media: intel/ipu6: Don't re-allocate memory for firmware

The ipu6 driver allocated vmalloc memory for the firmware if
request_firmware() somehow managed not to use vmalloc to allocate it.

Still how the memory is allocated by request_firmware() is not specified
in its API, so be prepared for kmalloc-allocated firmware, too. Instead of
allocating new vmalloc-backed buffer for the firmware, obtain the pages
from virtual addresses instead.

Link: https://lore.kernel.org/linux-media/20240502154950.549015-1-sakari.ailus@linux.intel.com
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Closes: https://lore.kernel.org/all/20240501102236.3b2585d1@canb.auug.org.au/
Fixes: 25fedc021985 ("media: intel/ipu6: add Intel IPU6 PCI device driver")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: dvb-frontends: tda10048: Fix integer overflow
Ricardo Ribalda [Mon, 29 Apr 2024 15:05:04 +0000 (16:05 +0100)]
media: dvb-frontends: tda10048: Fix integer overflow

state->xtal_hz can be up to 16M, so it can overflow a 32 bit integer
when multiplied by pll_mfactor.

Create a new 64 bit variable to hold the calculations.

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-25-3c4865f5a4b0@chromium.org
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: tc358746: Use the correct div_ function
Ricardo Ribalda [Mon, 29 Apr 2024 15:05:01 +0000 (16:05 +0100)]
media: tc358746: Use the correct div_ function

fin does not fit in 32 bits in some arches.

Found by cocci:
drivers/media/i2c/tc358746.c:847:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead.

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-22-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: i2c: st-mipid02: Use the correct div function
Ricardo Ribalda [Mon, 29 Apr 2024 15:05:00 +0000 (16:05 +0100)]
media: i2c: st-mipid02: Use the correct div function

link_freq does not fit in 32 bits.

Found by cocci:
drivers/media/i2c/st-mipid02.c:329:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_s64 instead.

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-21-3c4865f5a4b0@chromium.org
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: tegra-vde: Refactor timeout handling
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:59 +0000 (16:04 +0100)]
media: tegra-vde: Refactor timeout handling

Reorder the branches a bit, so cocci stops complaining about the code.

drivers/media/platform/nvidia/tegra-vde/h264.c:645:20-21: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-20-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: stk1160: Use min macro
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:58 +0000 (16:04 +0100)]
media: stk1160: Use min macro

Instead of a custom min() implementation, use the real macro.

Mitigates the following cocci WARNINGs:
drivers/media/usb/stk1160/stk1160-video.c:133:12-13: WARNING opportunity for min()
drivers/media/usb/stk1160/stk1160-video.c:176:13-14: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-19-3c4865f5a4b0@chromium.org
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: gspca: cpia1: Use min macro
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:57 +0000 (16:04 +0100)]
media: gspca: cpia1: Use min macro

Simplifies the code.

Found by cocci:
drivers/media/usb/gspca/cpia1.c:607:30-31: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-18-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: flexcop-usb: Use min macro
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:56 +0000 (16:04 +0100)]
media: flexcop-usb: Use min macro

Simplifies the code.

Found by cocci:
drivers/media/usb/b2c2/flexcop-usb.c:201:8-9: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-17-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: au0828: Use umin macro
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:55 +0000 (16:04 +0100)]
media: au0828: Use umin macro

Simplifies the code.

Found by cocci:
drivers/media/usb/au0828/au0828-video.c:605:11-12: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-16-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: netup_unidvb: Use min macro
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:54 +0000 (16:04 +0100)]
media: netup_unidvb: Use min macro

Simplify the code.

Found by cocci:
drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c:138:26-27: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-15-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: dvb-frontends: drx39xyj: Use min macro
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:53 +0000 (16:04 +0100)]
media: dvb-frontends: drx39xyj: Use min macro

Replace ternary assignments with min() to simplify and make the code
more readable.

Found by cocci:
drivers/media/dvb-frontends/drx39xyj/drxj.c:1447:23-24: WARNING opportunity for min()
drivers/media/dvb-frontends/drx39xyj/drxj.c:1662:21-22: WARNING opportunity for min()
drivers/media/dvb-frontends/drx39xyj/drxj.c:1685:24-25: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-14-3c4865f5a4b0@chromium.org
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: common: saa7146: Use min macro
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:52 +0000 (16:04 +0100)]
media: common: saa7146: Use min macro

Simplifies the code. Found by cocci:

drivers/media/common/saa7146/saa7146_hlp.c:125:36-37: WARNING opportunity for min()
drivers/media/common/saa7146/saa7146_hlp.c:154:41-42: WARNING opportunity for min()
drivers/media/common/saa7146/saa7146_hlp.c:286:35-36: WARNING opportunity for min()
drivers/media/common/saa7146/saa7146_hlp.c:289:35-36: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-13-3c4865f5a4b0@chromium.org
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: platform: mtk-mdp3: Use refcount_t for job_count
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:51 +0000 (16:04 +0100)]
media: platform: mtk-mdp3: Use refcount_t for job_count

Use an API that resembles more the actual use of job_count.

Found by cocci:
drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:527:5-24: WARNING: atomic_dec_and_test variation before object free at line 541.
drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:578:6-25: WARNING: atomic_dec_and_test variation before object free at line 581.

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-12-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: s2255: Use refcount_t instead of atomic_t for num_channels
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:50 +0000 (16:04 +0100)]
media: s2255: Use refcount_t instead of atomic_t for num_channels

Use an API that resembles more the actual use of num_channels.

Found by cocci:
drivers/media/usb/s2255/s2255drv.c:2362:5-24: WARNING: atomic_dec_and_test variation before object free at line 2363.
drivers/media/usb/s2255/s2255drv.c:1557:5-24: WARNING: atomic_dec_and_test variation before object free at line 1558.

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-11-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: staging: media: tegra-video: Use swap macro
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:49 +0000 (16:04 +0100)]
media: staging: media: tegra-video: Use swap macro

Makes the code simpler and cocci happier:

drivers/staging/media/tegra-video/tegra20.c:324:44-45: WARNING opportunity for swap()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-10-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: dvb-frontends: tda18271c2dd: Remove casting during div
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:47 +0000 (16:04 +0100)]
media: dvb-frontends: tda18271c2dd: Remove casting during div

do_div() divides 64 bits by 32. We were adding a casting to the divider
to 64 bits, for a number that fits perfectly in 32 bits. Remove it.

Found by cocci:
drivers/media/dvb-frontends/tda18271c2dd.c:355:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
drivers/media/dvb-frontends/tda18271c2dd.c:331:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-8-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: staging: sun6i-isp: Remove redundant printk
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:46 +0000 (16:04 +0100)]
media: staging: sun6i-isp: Remove redundant printk

platform_get_irq() already prints an error for us.

Found by cocci:
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c:389:2-9: line 389 is redundant because platform_get_irq() already prints an error

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-7-3c4865f5a4b0@chromium.org
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: stm32-dcmipp: Remove redundant printk
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:45 +0000 (16:04 +0100)]
media: stm32-dcmipp: Remove redundant printk

platform_get_irq() already prints an error message.

Also platform_get_irq() can never return 0, so lets fix the condition
now that we are at it.

Found by cocci:
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c:444:3-10: line 444 is redundant because platform_get_irq() already prints an error

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-6-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: go7007: Use min and max macros
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:44 +0000 (16:04 +0100)]
media: go7007: Use min and max macros

Replace ternary inline selection of f1 and f2 min max values with min()
and max() helper functions for the sake of readability and to make
coccinelle happier

drivers/media/usb/go7007/go7007-fw.c:1292:14-15: WARNING opportunity for max()
drivers/media/usb/go7007/go7007-fw.c:1293:14-15: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-5-3c4865f5a4b0@chromium.org
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: uvcvideo: Use max() macro
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:43 +0000 (16:04 +0100)]
media: uvcvideo: Use max() macro

It makes the code slightly more clear and makes cocci incredibly happy:

drivers/media/usb/uvc/uvc_ctrl.c:839:22-23: WARNING opportunity for max()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-4-3c4865f5a4b0@chromium.org
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: stb0899: Simplify check
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:41 +0000 (16:04 +0100)]
media: stb0899: Simplify check

chip_id is an unsigned number, it can never be < 0

Fixes cocci check:
drivers/media/dvb-frontends/stb0899_drv.c:1280:8-15: WARNING: Unsigned expression compared with zero: chip_id > 0

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-2-3c4865f5a4b0@chromium.org
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: pci: mgb4: Refactor struct resources
Ricardo Ribalda [Mon, 29 Apr 2024 15:04:40 +0000 (16:04 +0100)]
media: pci: mgb4: Refactor struct resources

The struct resource end field signifies the end address not the
relative offset from the start field i.e size == (end - start) + 1.

Amend the .end field to specify the end address not the relative size
from the offset as is currently given.

Fixes cocci check:
drivers/media/pci/mgb4/mgb4_regs.c:13:22-25: WARNING: Suspicious code. resource_size is maybe missing with res

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-1-3c4865f5a4b0@chromium.org
Reviewed-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: staging: media: starfive: Clean pad selection in isp_try_format()
Changhuang Liang [Tue, 12 Mar 2024 02:45:20 +0000 (02:45 +0000)]
media: staging: media: starfive: Clean pad selection in isp_try_format()

The code to select isp_dev->formats[] is overly complicated.  We can
just use the "pad" as the index.  This will making adding new pads
easier in future patches.  No functional change.

Link: https://lore.kernel.org/linux-media/20240312024520.11022-1-changhuang.liang@starfivetech.com
Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: mtk-vcodec: potential null pointer deference in SCP
Fullway Wang [Thu, 18 Jan 2024 02:35:06 +0000 (02:35 +0000)]
media: mtk-vcodec: potential null pointer deference in SCP

The return value of devm_kzalloc() needs to be checked to avoid
NULL pointer deference. This is similar to CVE-2022-3113.

Link: https://lore.kernel.org/linux-media/PH7PR20MB5925094DAE3FD750C7E39E01BF712@PH7PR20MB5925.namprd20.prod.outlook.com
Signed-off-by: Fullway Wang <fullwaywang@outlook.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: mxl5xx: Move xpt structures off stack
Nathan Chancellor [Fri, 12 Jan 2024 00:40:36 +0000 (00:40 +0000)]
media: mxl5xx: Move xpt structures off stack

When building for LoongArch with clang 18.0.0, the stack usage of
probe() is larger than the allowed 2048 bytes:

  drivers/media/dvb-frontends/mxl5xx.c:1698:12: warning: stack frame size (2368) exceeds limit (2048) in 'probe' [-Wframe-larger-than]
   1698 | static int probe(struct mxl *state, struct mxl5xx_cfg *cfg)
        |            ^
  1 warning generated.

This is the result of the linked LLVM commit, which changes how the
arrays of structures in config_ts() get handled with
CONFIG_INIT_STACK_ZERO and CONFIG_INIT_STACK_PATTERN, which causes the
above warning in combination with inlining, as config_ts() gets inlined
into probe().

This warning can be easily fixed by moving the array of structures off
of the stackvia 'static const', which is a better location for these
variables anyways because they are static data that is only ever read
from, never modified, so allocating the stack space is wasteful.

This drops the stack usage from 2368 bytes to 256 bytes with the same
compiler and configuration.

Link: https://lore.kernel.org/linux-media/20240111-dvb-mxl5xx-move-structs-off-stack-v1-1-ca4230e67c11@kernel.org
Cc: stable@vger.kernel.org
Closes: https://github.com/ClangBuiltLinux/linux/issues/1977
Link: https://github.com/llvm/llvm-project/commit/afe8b93ffdfef5d8879e1894b9d7dda40dee2b8d
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: cec: core: avoid confusing "transmit timed out" message
Hans Verkuil [Tue, 30 Apr 2024 10:13:47 +0000 (11:13 +0100)]
media: cec: core: avoid confusing "transmit timed out" message

If, when waiting for a transmit to finish, the wait is interrupted,
then you might get a "transmit timed out" message, even though the
transmit was interrupted and did not actually time out.

Set transmit_in_progress_aborted to true if the
wait_for_completion_killable() call was interrupted and ensure
that the transmit is properly marked as ABORTED.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: Yang, Chenyuan <cy54@illinois.edu>
Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/
Fixes: 590a8e564c6e ("media: cec: abort if the current transmit was canceled")
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: cec: core: avoid recursive cec_claim_log_addrs
Hans Verkuil [Thu, 22 Feb 2024 16:17:33 +0000 (16:17 +0000)]
media: cec: core: avoid recursive cec_claim_log_addrs

Keep track if cec_claim_log_addrs() is running, and return -EBUSY
if it is when calling CEC_ADAP_S_LOG_ADDRS.

This prevents a case where cec_claim_log_addrs() could be called
while it was still in progress.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: Yang, Chenyuan <cy54@illinois.edu>
Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/
Fixes: ca684386e6e2 ("[media] cec: add HDMI CEC framework (api)")
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: cec: cec-api: add locking in cec_release()
Hans Verkuil [Fri, 23 Feb 2024 12:25:55 +0000 (12:25 +0000)]
media: cec: cec-api: add locking in cec_release()

When cec_release() uses fh->msgs it has to take fh->lock,
otherwise the list can get corrupted.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: Yang, Chenyuan <cy54@illinois.edu>
Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/
Fixes: ca684386e6e2 ("[media] cec: add HDMI CEC framework (api)")
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: cec: cec-adap: always cancel work in cec_transmit_msg_fh
Hans Verkuil [Fri, 23 Feb 2024 12:24:38 +0000 (12:24 +0000)]
media: cec: cec-adap: always cancel work in cec_transmit_msg_fh

Do not check for !data->completed, just always call
cancel_delayed_work_sync(). This fixes a small race condition.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: Yang, Chenyuan <cy54@illinois.edu>
Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/
Fixes: 490d84f6d73c ("media: cec: forgot to cancel delayed work")
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: verisilicon: Correct a typo in H1_REG_MAD_CTRL_MAD_THRESHOLD
Andrzej Pietrasiewicz [Thu, 16 Nov 2023 15:48:12 +0000 (15:48 +0000)]
media: verisilicon: Correct a typo in H1_REG_MAD_CTRL_MAD_THRESHOLD

It's a THRESHOLD and not a THREDHOLD.

Link: https://lore.kernel.org/linux-media/20231116154816.70959-3-andrzej.p@collabora.com
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: verisilicon Correct a typo in H1_REG_ENC_CTRL2_DEBLOCKING_FILTER_MODE
Andrzej Pietrasiewicz [Thu, 16 Nov 2023 15:48:11 +0000 (15:48 +0000)]
media: verisilicon Correct a typo in H1_REG_ENC_CTRL2_DEBLOCKING_FILTER_MODE

It's a FILTER and not FILETER.

Link: https://lore.kernel.org/linux-media/20231116154816.70959-2-andrzej.p@collabora.com
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: sunxi: a83-mips-csi2: also select GENERIC_PHY
Randy Dunlap [Wed, 27 Sep 2023 04:04:38 +0000 (05:04 +0100)]
media: sunxi: a83-mips-csi2: also select GENERIC_PHY

When selecting GENERIC_PHY_MIPI_DPHY, also select GENERIC_PHY to
prevent kconfig warnings:

WARNING: unmet direct dependencies detected for GENERIC_PHY_MIPI_DPHY
  Depends on [n]: GENERIC_PHY [=n]
  Selected by [y]:
  - VIDEO_SUN8I_A83T_MIPI_CSI2 [=y] && MEDIA_SUPPORT [=y] && MEDIA_PLATFORM_SUPPORT [=y] && MEDIA_PLATFORM_DRIVERS [=y] && V4L_PLATFORM_DRIVERS [=y] && VIDEO_DEV [=y] && (ARCH_SUNXI || COMPILE_TEST [=y]) && PM [=y] && COMMON_CLK [=y] && RESET_CONTROLLER [=y]

Fixes: 94d7fd9692b5 ("media: sunxi: Depend on GENERIC_PHY_MIPI_DPHY")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/ZQ/WS8HC1A3F0Qn8@rli9-mobl
Link: https://lore.kernel.org/linux-media/20230927040438.5589-1-rdunlap@infradead.org
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: intel/ipu6: Fix direct dependency Kconfig error
Ricardo Ribalda [Wed, 1 May 2024 13:08:12 +0000 (14:08 +0100)]
media: intel/ipu6: Fix direct dependency Kconfig error

VIDEO_INTEL_IPU6 selects IPU6_BRIDGE, but they have different set of
dependencies.

It fixes this warning:
WARNING: unmet direct dependencies detected for IPU_BRIDGE
  Depends on [n]: MEDIA_SUPPORT [=y] && PCI [=y] && MEDIA_PCI_SUPPORT [=y] && I2C [=y] && ACPI [=n]
  Selected by [y]:
  - VIDEO_INTEL_IPU6 [=y] && MEDIA_SUPPORT [=y] && PCI [=y] && MEDIA_PCI_SUPPORT [=y] && (ACPI [=n] || COMPILE_TEST [=y]) && VIDEO_DEV [=y] && X86 [=y] && X86_64 [=y] && HAS_DMA [=y]

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: intel/ipu6: Fix build with !ACPI
Ricardo Ribalda [Wed, 1 May 2024 13:08:13 +0000 (14:08 +0100)]
media: intel/ipu6: Fix build with !ACPI

Modify the code so it can be compiled tested in configurations that do
not have ACPI enabled.

It fixes the following errors:
drivers/media/pci/intel/ipu-bridge.c:103:30: error: implicit declaration of function ‘acpi_device_handle’; did you mean ‘acpi_fwnode_handle’? [-Werror=implicit-function-declaration]
drivers/media/pci/intel/ipu-bridge.c:103:30: warning: initialization of ‘acpi_handle’ {aka ‘void *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
drivers/media/pci/intel/ipu-bridge.c:110:17: error: implicit declaration of function ‘for_each_acpi_dev_match’ [-Werror=implicit-function-declaration]
drivers/media/pci/intel/ipu-bridge.c:110:74: error: expected ‘;’ before ‘for_each_acpi_consumer_dev’
drivers/media/pci/intel/ipu-bridge.c:104:29: warning: unused variable ‘consumer’ [-Wunused-variable]
drivers/media/pci/intel/ipu-bridge.c:103:21: warning: unused variable ‘handle’ [-Wunused-variable]
drivers/media/pci/intel/ipu-bridge.c:166:38: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:185:43: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:191:30: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:196:30: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:202:30: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:223:31: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:236:18: error: implicit declaration of function ‘acpi_get_physical_device_location’ [-Werror=implicit-function-declaration]
drivers/media/pci/intel/ipu-bridge.c:236:56: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:238:31: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:256:31: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:275:31: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:280:30: error: invalid use of undefined type ‘struct acpi_device’
drivers/media/pci/intel/ipu-bridge.c:469:26: error: implicit declaration of function ‘acpi_device_hid’; did you mean ‘dmi_device_id’? [-Werror=implicit-function-declaration]
drivers/media/pci/intel/ipu-bridge.c:468:74: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Wformat=]
drivers/media/pci/intel/ipu-bridge.c:637:58: error: expected ‘;’ before ‘{’ token
drivers/media/pci/intel/ipu-bridge.c:696:1: warning: label ‘err_put_adev’ defined but not used [-Wunused-label]
drivers/media/pci/intel/ipu-bridge.c:693:1: warning: label ‘err_put_ivsc’ defined but not used [-Wunused-label]
drivers/media/pci/intel/ipu-bridge.c:691:1: warning: label ‘err_free_swnodes’ defined but not used [-Wunused-label]
drivers/media/pci/intel/ipu-bridge.c:632:40: warning: unused variable ‘primary’ [-Wunused-variable]
drivers/media/pci/intel/ipu-bridge.c:632:31: warning: unused variable ‘fwnode’ [-Wunused-variable]
drivers/media/pci/intel/ipu-bridge.c:733:73: error: expected ‘;’ before ‘{’ token
drivers/media/pci/intel/ipu-bridge.c:725:24: warning: unused variable ‘csi_dev’ [-Wunused-variable]
drivers/media/pci/intel/ipu-bridge.c:724:43: warning: unused variable ‘adev’ [-Wunused-variable]
drivers/media/pci/intel/ipu-bridge.c:599:12: warning: ‘ipu_bridge_instantiate_ivsc’ defined but not used [-Wunused-function]
drivers/media/pci/intel/ipu-bridge.c:444:13: warning: ‘ipu_bridge_create_connection_swnodes’ defined but not used [-Wunused-function]
drivers/media/pci/intel/ipu-bridge.c:297:13: warning: ‘ipu_bridge_create_fwnode_properties’ defined but not used [-Wunused-function]
drivers/media/pci/intel/ipu-bridge.c:155:12: warning: ‘ipu_bridge_check_ivsc_dev’ defined but not used [-Wunused-function]

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: intel/ipu6: Switch to RUNTIME_PM_OPS() and SYSTEM_SLEEP_PM_OPS
Ricardo Ribalda [Wed, 1 May 2024 13:08:11 +0000 (14:08 +0100)]
media: intel/ipu6: Switch to RUNTIME_PM_OPS() and SYSTEM_SLEEP_PM_OPS

Replace the old helpers with its modern alternative.
Now we do not need to set '__maybe_unused' annotations when we are not
enabling the PM configurations.

It fixes the following warnings:
drivers/media/pci/intel/ipu6/ipu6.c:841:12: warning: ‘ipu6_runtime_resume’ defined but not used [-Wunused-function]
drivers/media/pci/intel/ipu6/ipu6.c:806:12: warning: ‘ipu6_resume’ defined but not used [-Wunused-function]
drivers/media/pci/intel/ipu6/ipu6.c:801:12: warning: ‘ipu6_suspend’ defined but not used [-Wunused-function]

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: bcm2835-unicam: Include v4l2-subdev.h
Laurent Pinchart [Wed, 1 May 2024 13:08:10 +0000 (14:08 +0100)]
media: bcm2835-unicam: Include v4l2-subdev.h

The unicam driver uses the v4l2_subdev structure. Include the
corresponding header instead of relying on indirect includes.

Closes: https://lore.kernel.org/oe-kbuild-all/202404302324.8aTC84kE-lkp@intel.com/

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: bcm2835-unicam: Fix build with !PM
Ricardo Ribalda [Wed, 1 May 2024 13:08:09 +0000 (14:08 +0100)]
media: bcm2835-unicam: Fix build with !PM

The driver can only match the device vide the DT table, so the table
should always be used, of_match_ptr does not make sense here.

It fixes this warning:
drivers/media/platform/broadcom/bcm2835-unicam.c:2724:34: warning: ‘unicam_of_match’ defined but not used [-Wunused-const-variable=]

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: staging: max96712: fix copy-paste error
Ihor Matushchak [Sat, 14 Oct 2023 14:38:43 +0000 (15:38 +0100)]
media: staging: max96712: fix copy-paste error

Link: https://lore.kernel.org/linux-media/20231014143843.3409-1-ihor.matushchak@foobox.net
Signed-off-by: Ihor Matushchak <ihor.matushchak@foobox.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: ipu3: Use MODULE_FIRMWARE to add firmware files metadata
Víctor Gonzalo [Thu, 14 Sep 2023 13:51:00 +0000 (14:51 +0100)]
media: ipu3: Use MODULE_FIRMWARE to add firmware files metadata

The ipu3 driver requests firmware files but does not use the
MODULE_FIRMWARE macro to show them in the module metadata

[mchehab: add missing firmware file: IMGU_FW_NAME_IPU_20161208]
Link: https://lore.kernel.org/linux-media/20230914135100.19911-1-victor.gonzalo@anddroptable.net
Signed-off-by: Víctor Gonzalo <victor.gonzalo@anddroptable.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: cec: cec.h: 2.1 ms -> 2100 ms
Hans Verkuil [Fri, 18 Aug 2023 12:12:48 +0000 (13:12 +0100)]
media: cec: cec.h: 2.1 ms -> 2100 ms

The transfer timeout is 2100 ms, not 2.1 ms. Fix this in the
kerneldoc comment.

Link: https://lore.kernel.org/linux-media/17cd1a67-3966-237c-2e0d-2d3ae618f915@xs4all.nl
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: dw2102: fix a potential buffer overflow
Mauro Carvalho Chehab [Mon, 29 Apr 2024 14:15:05 +0000 (15:15 +0100)]
media: dw2102: fix a potential buffer overflow

As pointed by smatch:
 drivers/media/usb/dvb-usb/dw2102.c:802 su3000_i2c_transfer() error: __builtin_memcpy() '&state->data[4]' too small (64 vs 67)

That seemss to be due to a wrong copy-and-paste.

Fixes: 0e148a522b84 ("media: dw2102: Don't translate i2c read into write")

Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: IR remote control for AVerMedia TD310
Alex Volkov [Sun, 19 Mar 2023 08:23:15 +0000 (08:23 +0000)]
media: IR remote control for AVerMedia TD310

Uses NEC defaults as other non-eeprom devices.

Link: https://lore.kernel.org/linux-media/2273969.FyfRTN5kjP@bootes
Signed-off-by: Alex Volkov <alex@bootes.sytes.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: atomisp-mt9m114: adjust macro parameter name
Julia Lawall [Wed, 15 Mar 2023 09:09:04 +0000 (09:09 +0000)]
media: atomisp-mt9m114: adjust macro parameter name

The macro parameter name, sd, captures the field name in the third
argument of container_of.  Fortunately, the argument at all uses is
actually sd.  But change the macro parameter name anyway, for a little
added safety.

Link: https://lore.kernel.org/linux-media/20230315090904.20092-1-Julia.Lawall@inria.fr
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: dt-bindings: media: i2c: Rename ov8856.yaml
Lad Prabhakar [Fri, 16 Sep 2022 11:09:55 +0000 (12:09 +0100)]
media: dt-bindings: media: i2c: Rename ov8856.yaml

Rename 'ov8856.yaml' as 'ovti,ov8856.yaml' and update the MAINTAINERS
file entry accordingly.

All the Omnivision sensor DT bindings have vendor prefix "ovti," to
their file name hence this renaming.

Link: https://lore.kernel.org/linux-media/20220916110955.23757-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: uapi: v4l: Don't expose generic metadata formats to userspace
Laurent Pinchart [Fri, 26 Apr 2024 15:33:19 +0000 (18:33 +0300)]
media: uapi: v4l: Don't expose generic metadata formats to userspace

The generic metadata pixel formats (V4L2_META_FMT_GENERIC_*) are meant
to be used in conjunction with device-specific media bus codes. Those
codes are work in progress and not available in the upstream kernel yet.
To make sure the generic metadata pixel formats won't be used by
userspace until we have the full infrastructure in place, keep their
definition private to the kernel for now.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: Documentation: add documentation of Intel IPU6 driver and hardware overview
Bingbu Cao [Wed, 31 Jan 2024 09:51:07 +0000 (17:51 +0800)]
media: Documentation: add documentation of Intel IPU6 driver and hardware overview

Add a documentation for an overview of IPU6 hardware and describe the main
the components of IPU6 driver.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: Documentation: add Intel IPU6 ISYS driver admin-guide doc
Bingbu Cao [Wed, 31 Jan 2024 09:51:06 +0000 (17:51 +0800)]
media: Documentation: add Intel IPU6 ISYS driver admin-guide doc

This document mainly describe the functionality of IPU6 and IPU6 isys
driver, and gives an example that how user can do imaging capture with
tools.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: support line-based metadata capture support
Bingbu Cao [Wed, 31 Jan 2024 09:51:05 +0000 (17:51 +0800)]
media: intel/ipu6: support line-based metadata capture support

Some camera sensor can output the embedded data in specific data type.
This patch adds the support for metadata capture in IPU6 ISYS driver.

Signed-off-by: Hongju Wang <hongju.wang@intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: MAINTAINERS: add maintainers for Intel IPU6 input system driver
Bingbu Cao [Wed, 31 Jan 2024 09:51:05 +0000 (17:51 +0800)]
media: MAINTAINERS: add maintainers for Intel IPU6 input system driver

Update MAINTAINERS file for Intel IPU6 input system driver.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: add Kconfig and Makefile
Bingbu Cao [Wed, 31 Jan 2024 09:51:04 +0000 (17:51 +0800)]
media: intel/ipu6: add Kconfig and Makefile

Add Kconfig and Makefile for the IPU6 driver.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Andreas Helbech Kleist <andreaskleist@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: add the main input system driver
Bingbu Cao [Wed, 31 Jan 2024 09:51:02 +0000 (17:51 +0800)]
media: intel/ipu6: add the main input system driver

The main input system driver does basic ISYS hardware setup, IRQ handling
and sets up device nodes.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.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-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: input system video nodes and buffer queues
Bingbu Cao [Wed, 31 Jan 2024 09:51:03 +0000 (17:51 +0800)]
media: intel/ipu6: input system video nodes and buffer queues

Register V4L2 video device and setup the VB2 queues to support video
capture. Video streaming callback will trigger the input system driver to
construct a input system stream configuration for firmware based on data
type and stream ID and then queue buffers to firmware to do capture.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: add the CSI2 DPHY implementation
Bingbu Cao [Wed, 31 Jan 2024 09:51:01 +0000 (17:51 +0800)]
media: intel/ipu6: add the CSI2 DPHY implementation

IPU6 CSI-2 D-PHY hardware varies on different platforms, current IPU6 has
three D-PHY hardware instances which are used on Tigerlake, Alder lake,
Meteor lake and Jasper lake. MCD D-PHY is included in Tigerlake and Alder
lake, DWC D-PHY is included in Meteor lake.

Each PHY has its own register interface, the input system driver calls the
appropriate D-PHY callbacks for the hardware set in isys_probe().

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: add IPU6 CSI2 receiver v4l2 sub-device
Bingbu Cao [Wed, 31 Jan 2024 09:51:00 +0000 (17:51 +0800)]
media: intel/ipu6: add IPU6 CSI2 receiver v4l2 sub-device

Input system CSI2 receiver is exposed as a v4l2 sub-device. Each CSI2
sub-device represent one single CSI2 hardware port which be linked with
external sub-device such camera sensor by linked with ISYS CSI2's sink
pad. The CSI2 source pad is linked to the sink pad of video capture device.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: input system ABI between firmware and driver
Bingbu Cao [Wed, 31 Jan 2024 09:50:59 +0000 (17:50 +0800)]
media: intel/ipu6: input system ABI between firmware and driver

Implement the input system firmware ABIs in the ISYS driver, including
stream configuration, control command, capture request and response.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: add syscom interfaces between firmware and driver
Bingbu Cao [Wed, 31 Jan 2024 09:50:58 +0000 (17:50 +0800)]
media: intel/ipu6: add syscom interfaces between firmware and driver

Syscom is an inter-process(or) communication mechanism between an IPU and
host. Syscom uses message queues for message exchange between IPU and
host. Each message queue has its consumer and producer, host queue
messages to firmware as the producer and then firmware to dequeue the
messages as consumer and vice versa. IPU and host use shared registers or
memory to reside the read and write indices which are updated by consumer
and producer.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: add IPU6 DMA mapping API and MMU table
Bingbu Cao [Wed, 31 Jan 2024 09:50:57 +0000 (17:50 +0800)]
media: intel/ipu6: add IPU6 DMA mapping API and MMU table

The Intel IPU6 has internal microcontrollers (scalar processor, SP) which
are used to execute the firmware. The SPs can access IPU internal memory
and system DRAM mapped to its an internal 32-bit virtual address space.

This patch adds a driver for the IPU MMU and a DMA mapping implementation
using the internal MMU. The system IOMMU may be used besides the IPU MMU.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: CPD parsing for get firmware components
Bingbu Cao [Wed, 31 Jan 2024 09:50:56 +0000 (17:50 +0800)]
media: intel/ipu6: CPD parsing for get firmware components

For IPU6, firmware is generated and released as signed Code Partition
Directory (CPD) format file which is aligned with the SPI flash code
partition definition. The CPD format includes CPD header, manifest,
metadata and module data. The driver parses them according to the CPD
layout to acquire each component.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: add IPU6 buttress interface driver
Bingbu Cao [Wed, 31 Jan 2024 09:50:55 +0000 (17:50 +0800)]
media: intel/ipu6: add IPU6 buttress interface driver

The IPU6 buttress is the interface between IPU device (input system and
processing system) with rest of the SoC. It contains overall IPU hardware
control registers, these control registers are used as the interfaces with
the Intel Converged Security Engine and Punit to do firmware
authentication and power management.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: add IPU auxiliary devices
Bingbu Cao [Wed, 31 Jan 2024 09:50:54 +0000 (17:50 +0800)]
media: intel/ipu6: add IPU auxiliary devices

Even though the IPU input system and processing system are in a single PCI
device, each system has its own power sequence. Powering up the processing
system depends on first powering up the input system.

Besides, both the input and processing systems have their own MMU hardware
for IPU DMA address mapping.

Register the IS/PS devices on auxiliary bus and attach power domain to
implement the power sequence dependency.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: intel/ipu6: add Intel IPU6 PCI device driver
Bingbu Cao [Wed, 31 Jan 2024 09:50:53 +0000 (17:50 +0800)]
media: intel/ipu6: add Intel IPU6 PCI device driver

Intel Image Processing Unit 6th Gen includes input and processing systems
but the hardware presents itself as a single PCI device in system.

The IPU6 PCI device driver basically does PCI configurations and loads the
firmware binary, initialises IPU virtual bus and sets up platform specific
variants to support multiple IPU6 devices in single device driver.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: ivsc: csi: Use IPU bridge
Sakari Ailus [Tue, 13 Feb 2024 09:44:09 +0000 (11:44 +0200)]
media: ivsc: csi: Use IPU bridge

Use IPU bridge to instantiate software nodes for IPU6 related devices. If
the IPU6 device is probed before the MEI CSI device is created, neither
will probe unless there are further devices probed successfully which
triggers re-probe of both IPU6 and MEI CSI.

This patch ensures the necessary software nodes are in place when the MEI
CSI driver is probed.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: ipu6: Add PCI device table header
Sakari Ailus [Tue, 13 Feb 2024 09:00:28 +0000 (11:00 +0200)]
media: ipu6: Add PCI device table header

Add a header for the PCI device table of all IPU6 devices. This will be
used by the IPU bridge as well so place the table in a header.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: bcm2835-unicam: Add support for CCP2/CSI2 camera interface
Dave Stevenson [Wed, 24 Apr 2024 15:35:40 +0000 (18:35 +0300)]
media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface

Add a driver for the Unicam camera receiver block on BCM283x processors.
It is represented as two video device nodes: unicam-image and
unicam-embedded which are connected to an internal subdev (named
unicam-subdev) in order to manage streams routing.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Co-developed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Co-developed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Sakari Ailus: Squash fixes by Laurent.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agodt-bindings: media: Add bindings for bcm2835-unicam
Dave Stevenson [Wed, 24 Apr 2024 15:35:39 +0000 (18:35 +0300)]
dt-bindings: media: Add bindings for bcm2835-unicam

Introduce the dt-bindings documentation for bcm2835 CCP2/CSI2 Unicam
camera interface.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Co-developed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Co-developed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: Add V4L2-PIX-FMT-Y14P format
Jean-Michel Hautbois [Wed, 24 Apr 2024 15:35:38 +0000 (18:35 +0300)]
media: v4l: Add V4L2-PIX-FMT-Y14P format

This is a packed grey-scale image format with a depth of 14 bits per
pixel. Every four consecutive samples are packed into seven bytes. Each
of the first four bytes contain the eight high order bits of the pixels,
and the three following bytes contains the six least significants bits
of each pixel, in the same order.

As the other formats only needed 5 bytes before, append two bytes in the
documentation array.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: Add V4L2-PIX-FMT-Y12P format
Jean-Michel Hautbois [Wed, 24 Apr 2024 15:35:37 +0000 (18:35 +0300)]
media: v4l: Add V4L2-PIX-FMT-Y12P format

This is a packed grey-scale image format with a depth of 12 bits per
pixel. Two consecutive pixels are packed into 3 bytes. The first 2 bytes
contain the 8 high order bits of the pixels, and the 3rd byte contains
the 4 least significants bits of each pixel, in the same order.

Add the entry in userspace API, and document it.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: subdev: Add trivial set_routing support
Sakari Ailus [Thu, 31 Aug 2023 12:40:07 +0000 (15:40 +0300)]
media: v4l: subdev: Add trivial set_routing support

Add trivial S_ROUTING IOCTL support for drivers where routing is static.
Essentially this means returning the same information G_ROUTING call would
have done.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: subdev: Return routes set using S_ROUTING
Sakari Ailus [Wed, 6 Sep 2023 10:51:04 +0000 (13:51 +0300)]
media: v4l: subdev: Return routes set using S_ROUTING

Return the routes set using S_ROUTING back to the user. Also reflect this
in documentation.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: subdev: Add len_routes field to struct v4l2_subdev_routing
Sakari Ailus [Thu, 31 Aug 2023 11:56:28 +0000 (14:56 +0300)]
media: v4l: subdev: Add len_routes field to struct v4l2_subdev_routing

The len_routes field is used to tell the size of the routes array in
struct v4l2_subdev_routing. This way the number of routes returned from
S_ROUTING IOCTL may be larger than the number of routes provided, in case
there are more routes returned by the driver.

Note that this uAPI is still disabled in the code, so this change can
safely be done. Anyone who manually patched the code to enable this uAPI
must update their code.

The patch also increases the number of reserved fields in struct
v4l2_subdev_routing.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: subdev: Copy argument back to user also for S_ROUTING
Sakari Ailus [Thu, 31 Aug 2023 11:40:29 +0000 (14:40 +0300)]
media: v4l: subdev: Copy argument back to user also for S_ROUTING

As the user needs to know what went wrong for S_ROUTING, copy array
arguments back to the user.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: subdev: Add a function to lock two sub-device states, use it
Sakari Ailus [Wed, 6 Sep 2023 07:56:14 +0000 (10:56 +0300)]
media: v4l: subdev: Add a function to lock two sub-device states, use it

Add two new functions, v4l2_subdev_lock_states() and
v4l2_subdev_unclock_states(), to acquire and release the state of two
sub-devices. They differ from calling v4l2_subdev_{un,}lock_state() so
that if the two states share the same lock, the lock is acquired only
once.

Also use the new functions in v4l2_subdev_link_validate().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: Documentation: Document S_ROUTING behaviour
Sakari Ailus [Thu, 21 Sep 2023 09:12:49 +0000 (12:12 +0300)]
media: Documentation: Document S_ROUTING behaviour

Document S_ROUTING behaviour for different devices.

Generally in devices that produce streams the streams are static and some
can be enabled and disabled, whereas in devices that just transport them
or write them to memory, more configurability is allowed. Document this.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: Documentation: Additional streams generally don't harm capture
Sakari Ailus [Thu, 21 Sep 2023 11:51:30 +0000 (14:51 +0300)]
media: Documentation: Additional streams generally don't harm capture

Having extra streams on the source end of the link that cannot be captured
by the sink sub-device generally are not an issue, at least not on CSI-2
bus. Still document that there may be hardware-specific limitations. For
example on parallel bus this might not work on all cases.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: Set line based metadata flag in V4L2 core
Sakari Ailus [Tue, 23 Apr 2024 07:39:47 +0000 (10:39 +0300)]
media: v4l: Set line based metadata flag in V4L2 core

Set (and unset) the V4L2_FMT_FLAG_META_LINE_BASED flag in struct
v4l2_fmtdesc based on the format after returning the driver callback for
enumerating formats. This way the drivers don't need to care about the
flag.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l: Support line-based metadata capture
Sakari Ailus [Tue, 21 Feb 2023 17:37:29 +0000 (19:37 +0200)]
media: v4l: Support line-based metadata capture

Many camera sensors, among other devices, transmit embedded data and image
data for each CSI-2 frame. This embedded data typically contains register
configuration of the sensor that has been used to capture the image data
of the same frame.

The embedded data is received by the CSI-2 receiver and has the same
properties as the image data, including that it is line based: it has
width, height and bytesperline (stride).

Add these fields to struct v4l2_meta_format and document them.

Also add V4L2_FMT_FLAG_META_LINE_BASED to tell a given format is
line-based i.e. these fields of struct v4l2_meta_format are valid for it.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: uapi: v4l: Add generic 8-bit metadata format definitions
Sakari Ailus [Wed, 26 Apr 2023 10:28:48 +0000 (13:28 +0300)]
media: uapi: v4l: Add generic 8-bit metadata format definitions

Generic 8-bit metadata formats define the in-memory data layout but not
the format of the data itself. The reasoning for having such formats is to
allow CSI-2 receiver drivers to receive and DMA drivers to write the data
to memory without knowing a large number of device-specific formats.

These formats may be used only in conjunction with a Media Controller
pipeline where the internal pad of the source sub-device defines the
specific format of the data (using an mbus code).

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: uapi: Document which mbus format fields are valid for metadata
Sakari Ailus [Tue, 1 Aug 2023 13:15:36 +0000 (16:15 +0300)]
media: uapi: Document which mbus format fields are valid for metadata

Now that metadata mbus formats have been added, it is necessary to define
which fields in struct v4l2_mbus_format are applicable to them (not many).

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: uapi: Add generic serial metadata mbus formats
Sakari Ailus [Tue, 25 Apr 2023 13:50:25 +0000 (16:50 +0300)]
media: uapi: Add generic serial metadata mbus formats

Add generic serial metadata mbus formats. These formats describe data
width and packing but not the content itself. The reason for specifying
such formats is that the formats as such are fairly device specific but
they are still handled by CSI-2 receiver drivers that should not be aware
of device specific formats. What makes generic metadata formats possible
is that these formats are parsed by software only, after capturing the
data to system memory.

Also add a definition for "Data Unit" to cover what is essentially a pixel
but is not image data.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: Documentation: Add "stream" into glossary
Sakari Ailus [Wed, 11 Oct 2023 18:33:19 +0000 (21:33 +0300)]
media: Documentation: Add "stream" into glossary

Add term "stream" to the glossary of the Media subsystem documentation.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: v4l2-subdev: Clearly document that the crop API won't be extended
Laurent Pinchart [Mon, 1 Apr 2024 23:37:25 +0000 (02:37 +0300)]
media: v4l2-subdev: Clearly document that the crop API won't be extended

The V4L2 subdev crop API has been marked as obsolete, deprecated by the
selection API. Despite this, it has recently been extended with streams
support. In hindsight this was a mistake. Make sure it doesn't happen
again by clearly documenting that no new extensions will be accepted.

Suggested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
4 months agomedia: si2165: Remove redundant NULL check before release_firmware() call
Minghao Chi [Mon, 6 Jun 2022 01:44:33 +0000 (02:44 +0100)]
media: si2165: Remove redundant NULL check before release_firmware() call

release_firmware() checks for NULL pointers internally so checking
before calling it is redundant.

Link: https://lore.kernel.org/linux-media/20220606014433.290667-1-chi.minghao@zte.com.cn
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Acked-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: flexcop-usb: fix sanity check of bNumEndpoints
Dongliang Mu [Thu, 2 Jun 2022 05:50:24 +0000 (06:50 +0100)]
media: flexcop-usb: fix sanity check of bNumEndpoints

Commit d725d20e81c2 ("media: flexcop-usb: sanity checking of endpoint type
") adds a sanity check for endpoint[1], but fails to modify the sanity
check of bNumEndpoints.

Fix this by modifying the sanity check of bNumEndpoints to 2.

Link: https://lore.kernel.org/linux-media/20220602055027.849014-1-dzm91@hust.edu.cn
Fixes: d725d20e81c2 ("media: flexcop-usb: sanity checking of endpoint type")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: flexcop: allow for modern speeds
Oliver Neukum [Tue, 17 May 2022 13:11:09 +0000 (14:11 +0100)]
media: flexcop: allow for modern speeds

High speed is no longer the ultimate in speed.

Link: https://lore.kernel.org/linux-media/20220517131109.28371-2-oneukum@suse.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: flexcop: unneeded ATOMIC
Oliver Neukum [Tue, 17 May 2022 13:11:08 +0000 (14:11 +0100)]
media: flexcop: unneeded ATOMIC

No need for GFP_ATOMIC during probe()

Link: https://lore.kernel.org/linux-media/20220517131109.28371-1-oneukum@suse.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: as102: avoid GFP_ATOMIC
Oliver Neukum [Tue, 17 May 2022 11:10:49 +0000 (12:10 +0100)]
media: as102: avoid GFP_ATOMIC

No need for GFP_ATOMIC during probe()

Link: https://lore.kernel.org/linux-media/20220517111049.25611-1-oneukum@suse.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: imx214: Fix the error handling in imx214_probe()
Zheyu Ma [Tue, 10 May 2022 11:48:52 +0000 (12:48 +0100)]
media: imx214: Fix the error handling in imx214_probe()

The driver should disable regulators when fails to probe.

Link: https://lore.kernel.org/linux-media/20220510114852.1719018-1-zheyuma97@gmail.com
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 months agomedia: lgdt3306a: Add a check against null-pointer-def
Zheyu Ma [Tue, 5 Apr 2022 09:50:18 +0000 (10:50 +0100)]
media: lgdt3306a: Add a check against null-pointer-def

The driver should check whether the client provides the platform_data.

The following log reveals it:

[   29.610324] BUG: KASAN: null-ptr-deref in kmemdup+0x30/0x40
[   29.610730] Read of size 40 at addr 0000000000000000 by task bash/414
[   29.612820] Call Trace:
[   29.613030]  <TASK>
[   29.613201]  dump_stack_lvl+0x56/0x6f
[   29.613496]  ? kmemdup+0x30/0x40
[   29.613754]  print_report.cold+0x494/0x6b7
[   29.614082]  ? kmemdup+0x30/0x40
[   29.614340]  kasan_report+0x8a/0x190
[   29.614628]  ? kmemdup+0x30/0x40
[   29.614888]  kasan_check_range+0x14d/0x1d0
[   29.615213]  memcpy+0x20/0x60
[   29.615454]  kmemdup+0x30/0x40
[   29.615700]  lgdt3306a_probe+0x52/0x310
[   29.616339]  i2c_device_probe+0x951/0xa90

Link: https://lore.kernel.org/linux-media/20220405095018.3993578-1-zheyuma97@gmail.com
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>