aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/atomisp (follow)
AgeCommit message (Collapse)AuthorFilesLines
2025-08-29media: atomisp: Fix incorrect snprintf format specifiers for signed integersColin Ian King1-2/+2
There are incorrect %u format specifiers being used to for signed integers, fix this by using %d instead. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
2025-08-25media: Move gc0310 sensor drivers to drivers/media/i2c/Hans de Goede3-793/+0
The atomisp gc0310 sensor driver has now been fully converted to a standard v4l2 sensor driver. Move it to drivers/media/i2c/ to reflect this. 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@kernel.org>
2025-08-25media: staging: atomisp: Drop custom .unsubscribe_event() handlerLaurent Pinchart1-8/+1
The isp_subdev_unsubscribe_event() function simply calls v4l2_event_unsubscribe(), forwarding its arguments. Replace it with the v4l2_event_subdev_unsubscribe() helper that performs exactly the same operation. 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@kernel.org>
2025-07-31Merge tag 'media/v6.17-1' of ↵Linus Torvalds43-1140/+527
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media Pull media updates from Mauro Carvalho Chehab: - v4l2 core: - sub-device framework routing improvements - NV12M tiled variants added to v4l2_format_info - some fixes at control handler freeing logic - fixed H264 SEPARATE_COLOUR_PLANE check - new staging driver: Intel IPU7 PCI - Rockchip video decoder driver got promoted from staging - iris: added HEVC/VP9 encoder/decoder support - vsp1: driver has gained Renesas VSPX support - uvc: - switched to vb2 ioctl helpers - added MSXU 1.5 metadata support - atomisp: GC0310 sensor driver cleanups in preparation for moving it out of staging - Lots of cleanup, fixes and improvements * tag 'media/v6.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (310 commits) media: rkvdec: Unstage the driver media: rkvdec: Remove TODO file media: dt-bindings: rockchip: Add RK3576 Video Decoder bindings media: dt-bindings: rockchip: Document RK3588 Video Decoder bindings media: amphion: Support dmabuf and v4l2 buffer without binding media: verisilicon: postproc: 4K support media: v4l2: Add support for NV12M tiled variants to v4l2_format_info() media: uvcvideo: Use a count variable for meta_formats instead of 0 terminating media: uvcvideo: Auto-set UVC_QUIRK_MSXU_META media: uvcvideo: Introduce V4L2_META_FMT_UVC_MSXU_1_5 media: uvcvideo: Introduce dev->meta_formats media: Documentation: Add note about UVCH length field media: uvcvideo: Do not mark valid metadata as invalid media: uvcvideo: uvc_v4l2_unlocked_ioctl: Invert PM logic media: core: export v4l2_translate_cmd media: uvcvideo: Turn on the camera if V4L2_EVENT_SUB_FL_SEND_INITIAL media: uvcvideo: Remove stream->is_streaming field media: uvcvideo: Split uvc_stop_streaming() media: uvcvideo: Handle locks in uvc_queue_return_buffers media: uvcvideo: Use vb2 ioctl and fop helpers ...
2025-07-28staging: media: atomisp: Fix stack buffer overflow in gmin_get_var_int()Kees Cook1-4/+5
When gmin_get_config_var() calls efi.get_variable() and the EFI variable is larger than the expected buffer size, two behaviors combine to create a stack buffer overflow: 1. gmin_get_config_var() does not return the proper error code when efi.get_variable() fails. It returns the stale 'ret' value from earlier operations instead of indicating the EFI failure. 2. When efi.get_variable() returns EFI_BUFFER_TOO_SMALL, it updates *out_len to the required buffer size but writes no data to the output buffer. However, due to bug #1, gmin_get_var_int() believes the call succeeded. The caller gmin_get_var_int() then performs: - Allocates val[CFG_VAR_NAME_MAX + 1] (65 bytes) on stack - Calls gmin_get_config_var(dev, is_gmin, var, val, &len) with len=64 - If EFI variable is >64 bytes, efi.get_variable() sets len=required_size - Due to bug #1, thinks call succeeded with len=required_size - Executes val[len] = 0, writing past end of 65-byte stack buffer This creates a stack buffer overflow when EFI variables are larger than 64 bytes. Since EFI variables can be controlled by firmware or system configuration, this could potentially be exploited for code execution. Fix the bug by returning proper error codes from gmin_get_config_var() based on EFI status instead of stale 'ret' value. The gmin_get_var_int() function is called during device initialization for camera sensor configuration on Intel Bay Trail and Cherry Trail platforms using the atomisp camera stack. Reported-by: zepta <z3ptaa@gmail.com> Closes: https://lore.kernel.org/all/CAPBS6KoQyM7FMdPwOuXteXsOe44X4H3F8Fw+y_qWq6E+OdmxQA@mail.gmail.com Fixes: 38d4f74bc148 ("media: atomisp_gmin_platform: stop abusing efivar API") Reviewed-by: Hans de Goede <hansg@kernel.org> Link: https://lore.kernel.org/r/20250724080756.work.741-kees@kernel.org Signed-off-by: Kees Cook <kees@kernel.org>
2025-07-08media: atomisp: Remove custom sysfs attributes from atomisp_drvfs.cAbdelrahman Fekry5-177/+0
Continue the cleanup of the AtomISP driver, as discussed with Hans and Andy in [1]. Tackle TODO item: "Remove custom sysfs files created by atomisp_drvfs.c": - Remove the sysfs attributes `dbglvl`, `dbgfun`, and `dbgopt`. - Delete their associated show/store handler functions. - Remove the corresponding attribute group definitions. Link: https://lore.kernel.org/all/836dc6b6-2821-47fc-8f24-0838f979af76@kernel.org/ [1] Suggested-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Abdelrahman Fekry <abdelrahmanfekry375@gmail.com> Link: https://lore.kernel.org/r/20250704161051.16733-1-abdelrahmanfekry375@gmail.com [hansg@kernel.org: Completely remove the now empty atomisp_drvfs files] Reviewed-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Fix premature setting of HMM_BO_DEVICE_INITED flagAbdelrahman Fekry1-3/+2
The HMM_BO_DEVICE_INITED flag was being set in hmm_bo_device_init() before key initialization steps like kmem_cache_create(), kmem_cache_alloc(), and __bo_init(). This means that if any of these steps fail, the flag remains set, misleading other parts of the driver (e.g. hmm_bo_alloc()) into thinking the device is initialized. This could lead to undefined behavior or invalid memory use. Additionally, since __bo_init() is called from inside hmm_bo_device_init() after the flag was already set, its internal check for HMM_BO_DEVICE_INITED is redundant. - Move the flag assignment to the end after all allocations succeed. - Remove redundant check of the flag inside __bo_init() See the link [1] below for a backtrace which happens when deliberately triggering the problem of the flag getting set too early. Link: https://lore.kernel.org/linux-media/CAGn2d8ONZpOHXex8kjeUDgRPiMqKp8vZ=xhGbEDGphV1t7ZEFw@mail.gmail.com/ [1] Signed-off-by: Abdelrahman Fekry <abdelrahmanfekry375@gmail.com> Link: https://lore.kernel.org/r/20250628052536.43737-1-abdelrahmanfekry375@gmail.com Reviewed-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Remove debug sysfs attributes active_bo and free_boAbdelrahman Fekry1-91/+0
The sysfs attributes active_bo and free_bo expose internal buffer state used only for debugging purposes. These are not part of any standard kernel ABI, and need to be removed before this driver may be moved out of drivers/staging. - Remove active_bo and free_bo attributes - Remove group registration calls form hmm_init() and hmm_cleanup() Suggested-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Abdelrahman Fekry <abdelrahmanfekry375@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/20250627100604.29061-1-abdelrahmanfekry375@gmail.com Reviewed-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Remove no more used macros from math_support.hAndy Shevchenko1-5/+0
After recent cleanups the few macros become unused. Remove them. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20250519155028.526453-4-andriy.shevchenko@linux.intel.com Reviewed-by: Hans de Goede <hansg@kernel.org> Tested-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Replace macros from math_support.hAndy Shevchenko15-66/+77
Replace rarely used macros by generic ones from Linux kernel headers. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20250519155028.526453-3-andriy.shevchenko@linux.intel.com Reviewed-by: Hans de Goede <hansg@kernel.org> Tested-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Remove unused headerAndy Shevchenko3-161/+0
There are some unused definitions that are using macros from math_support.h. In order to have cleaner future changes, remove them first. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20250519155028.526453-2-andriy.shevchenko@linux.intel.com Reviewed-by: Hans de Goede <hansg@kernel.org> Tested-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: ov2722: Fix struct definition styleThomas Andreatta1-8/+8
Reorder const qualifier in array declaration. Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com> Link: https://lore.kernel.org/r/20250619084420.146151-4-thomas.andreatta2000@gmail.com Reviewed-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc2235: Fix struct definition styleThomas Andreatta1-8/+8
Reorder const qualifier in array declaration. Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com> Link: https://lore.kernel.org/r/20250619084420.146151-3-thomas.andreatta2000@gmail.com Reviewed-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Remove redundant debug messageThomas Andreatta1-2/+0
Checkpatch fix: deleted `dev_dbg()` printing the name of the function. ftrace can be used instead. Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com> Link: https://lore.kernel.org/r/20250619084420.146151-2-thomas.andreatta2000@gmail.com Reviewed-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Drop gc0310_g_skip_frames()Hans de Goede1-11/+0
The g_skip_frames sensor-op is obsolete, drop it. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-23-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Drop gc0310_get_frame_interval()Hans de Goede1-18/+0
On raw camera sensors the framerate is controlled through vblank (and optional) hblank controls. Having a get_frame_interval makes no sense in this case, drop it. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-22-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: runtime-PM fixesHans de Goede1-30/+28
The i2c-client's power-domain has already been powered up when probe() gets called. So e.g. ACPI resources for regulators and clks have already been enabled and only the GPIOs need to be set to the on state. Instead of calling pm_runtime_set_suspended() while the domain is already powered up and then have detect() do a pm_runtime_get() to set the GPIOs do the following: 1. Call gc0310_power_on() to only set the GPIOs 2. Set the device's runtime-PM state to active instead of suspended 3. Avoid the device getting suspended as soon as pm_runtime_enable() gets called by calling pm_runtime_get() before _enable(), this means moving the pm_runtime_get() / _put() from detect() to probe () This fixes power_on() not getting called when runtime-PM is not enabled in the Kconfig and this keeps the sensor powered-up while registering it avoiding unnecessary power cycles. Also modify gc0310_remove() to power-off the device if it is in active state when gc0310_remove() runs. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-21-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Move and rename suspend/resume functionsHans de Goede1-25/+26
Move the suspend()/resume() functions to above gc0310_detect() and rename the functions to power_off()/power_on(). No functional changes, this is a preparation patch for reworking the runtime-pm handling in probe() and remove(). Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-20-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Switch to using sd.active_state fmtHans de Goede1-31/+1
Stop having a v4l2_mbus_framefmt mode.fmt driver-data member to store the fmt for the active-state, instead use sd.active_state fmt. This also removes the need for gc0310_get_pad_format() since v4l2_subdev_state_get_format() now will return the correct v4l2_mbus_framefmt for all whence values. Instead of switching gc0310_set_fmt() from gc0310_get_pad_format() to v4l2_subdev_state_get_format() just drop it entirely since there is only 1 fixed mode. Otherwise the new gc0310_set_fmt() would be 100% the same as v4l2_subdev_get_fmt() after this. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-19-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Use v4l2_subdev_get_fmt() as ↵Hans de Goede1-13/+1
v4l2_subdev_pad_ops.get_fmt() Now that the sd-state's fmt is properly initialized by internal_ops.init_state(), the driver can be safely switched to v4l2_subdev_get_fmt(). Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-18-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Implement internal_ops.init_stateHans de Goede1-0/+12
Implement internal_ops.init_state to fill in the v4l2_mbus_framefmt struct in newly allocated sd-state structs. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-17-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Switch to using the sub-device state lockHans de Goede1-13/+9
Switch to using the sub-device state lock and properly call v4l2_subdev_init_finalize() / v4l2_subdev_cleanup() on probe() / remove(). Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-16-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Switch to {enable,disable}_streamsHans de Goede1-32/+47
Switch from s_stream() to enable_streams() and disable_streams() pad operations. They are preferred and required for streams support. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-15-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Remove unused is_streaming variableHans de Goede1-3/+0
is_streaming is only set and never read, drop it. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-14-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Fix power on/off sleep timesHans de Goede1-4/+3
Reduce the unnecessary long msleep(100) done on stream start to 10 ms and move this to gc0310_resume() so that it is also done on the initial power-up done by gc0310_detect(), which should fix gc0310_detect() sometimes failing. While at it switch the sleeps from msleep() / usleep_range() to fsleep(). Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-13-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Add check_hwcfg() functionHans de Goede1-4/+52
Add a check_hwcfg() function to check if the external clk-freq, CSI link-freq and lane-count match the driver's expectations. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-12-hansg@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Limit max exposure value to mode-height + vblankHans de Goede1-2/+19
When an exposure value > (mode-height + vblank) gets set the sensor will automatically increase vblank, lowering the framerate. This is not desirable, limit exposure the maximum exposure to mode-height + vblank to avoid the unwanted framerate slowdown. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-11-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Add camera orientation and sensor rotation controlsHans de Goede1-1/+11
Add camera orientation and sensor rotation controls using the v4l2_fwnode_device_parse() and v4l2_ctrl_new_fwnode_properties() helpers. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-10-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Add vblank and hblank controlsHans de Goede1-3/+35
Add support for the vblank and hblank controls, these controls are mandatory for using the sensor driver with libcamera. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-9-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Add link-frequency and pixelrate controlsHans de Goede1-2/+31
Add support for the pixelrate control as expected by libcamera, while at it also add the link-frequency control. Signed-off-by: Hans de Goede <hansg@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-8-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Add selection API supportHans de Goede1-1/+26
Add support for the selection API as expected by libcamera. Note the driver only supports a single fixed resolution and no cropping, so this is a simple read-only implementation. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-7-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Use V4L2_CID_ANALOGUE_GAIN for gain controlHans de Goede1-2/+2
Use V4L2_CID_ANALOGUE_GAIN for gain control, as expected by userspace. Signed-off-by: Hans de Goede <hansg@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-6-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Switch to CCI register access helpersHans de Goede2-89/+55
Switch the GC0310 driver over to the CCI register access helpers. While at it also add a _REG prefix to all register address defines to make clear they are register addresses and group register value defines together with the address definition. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-5-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Modify vblank value to run at 30 fpsHans de Goede1-1/+1
Currently the sensor is running 30.9 fps, increase vblank to have it actually run at 30.0 fps. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-4-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Drop unused GC0310_FOCAL_LENGTH_NUM defineHans de Goede1-2/+0
Drop the unused GC0310_FOCAL_LENGTH_NUM define, the focal-length is a property of the sensor-module, not of the raw sensor itself. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-3-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: gc0310: Rename "dev" function variable to "sensor"Hans de Goede1-56/+56
Many functions on the gc0310 driver use a function local variable called "dev" but these variable's type is not "struct device *" type as one would expect based on the name. Instead they point to the gc0310 driver data struct. Rename these variables to sensor to make their purpose more clear. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250517114106.43494-2-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Fix ia_css_vf.host.c coding stylePablo1-2/+1
Fix a coding style: "ERROR: that open brace { should be on the previous line" issue reported in ia_css_vf.host.c:94. Signed-off-by: Pablo <pablo@pablo.ct.ws> Link: https://lore.kernel.org/r/20250503200030.5982-1-pablo@pablo.ct.ws Signed-off-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Switch to int3472 driver sensor GPIO mapping codeHans de Goede4-225/+27
Replace the duplicate code for calling the special Intel camera sensor GPIO type _DSM (79234640-9e10-4fea-a5c1-b5aa8b19756f) and mapping GPIOs to the sensor with a call to int3472_discrete_parse_crs() from the int3472 driver. Besides avoiding code duplication the int3472 version of the code also supports more features, like mapping the powerdown GPIO to a regulator on the mt9m114 which is necessary to make the camera on the Asus T100TA work. Signed-off-by: Hans de Goede <hansg@kernel.org> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Link: https://lore.kernel.org/r/20250507184737.154747-7-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Fix "stop stream timeout." errorHans de Goede4-26/+4
Commit c7194b21809e ("media: atomisp: On streamoff wait for buffers owned by the CSS to be given back") added draining of the CSS buffer queue to the beginning of atomisp_stop_stream(). But it turns out that when telling the CSS to stop streaming it needs at least 1 buffer queued, because the CSS firmware waits for a frame to be completed before stopping and without buffers it cannot complete a frame. At the end of atomisp_stop_stream() it is always safe to return buffer ownership to the videobuf2-core. Either atomisp_css_stop() has successfully stopped the stream; or the atomisp_reset() later on which power-cycles the ISP will definitely have stopped the stream. Drop the draining of the CSS buffer queue to fix the "stop stream timeout." error and move the atomisp_flush_video_pipe() call after atomisp_reset(), passing false for the warn_on_css_frames flag since some buffers still being marked as owned by the CSS expected on stream off. Also increase the timeout in destroy_stream(), since this waits for the last frame to be completed this can take longer then 40 ms. When e.g. using a framerate of 15 fps, this could take 66ms, make the timeout 200 ms to be on the safe side. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250505210008.152659-6-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Always free MIPI / CSI-receiver buffers from ia_css_uninit()Hans de Goede6-45/+0
The atomisp interrupt handling will free the MIPI / CSI-receiver buffers when processing a frame-completion event if the stop_requested flag is set, but only in the ISP2400 / BYT, not in the ISP2401 / CHT case. There are 2 problems with this: 1. Since this is only done in the BYT case the "mipi frames are not freed." warning always triggers on CHT devices. 2. There are 2 stop_requested flags, ia_css_pipe.stop_requested and ia_css_pipeline.stop_requested. The ISR checks the ia_css_pipe flag, but atomisp_css_stop() sets the ia_css_pipeline.stop_requested flag. So even on BYT freeing the buffers from the ISR never happens. This likely is a good thing since the buffers get freed on the first frame completion event and there might be multiple frames queued up. Fix things by completely dropping the freeing of the MIPI buffers from the ISR as well as the stop_requested flag always freeing the buffers from ia_css_uninit(). Also drop the warning since this now always is expected behavior. Note that ia_css_uninit() get called whenever streaming is stopped through atomisp_stop_stream() calling atomisp_reset() so the buffers are still freed whenever streaming is stopped. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250505210008.152659-5-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Stop pipeline on atomisp_css_start() failureHans de Goede1-0/+1
atomisp_start_streaming() starts the media pipeline before calling atomisp_css_start(). On atomisp_css_start() failures stop the pipeline before returning the error. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250505210008.152659-4-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Properly stop the ISP stream on sensor streamon errorsHans de Goede1-16/+22
When v4l2_subdev_call(sensor, s_stream, 1) fails atomisp_start_streaming() was not properly returning the buffer ownership back to the videobuf2-core code, resulting in: [ 1318.153447] ------------[ cut here ]------------ [ 1318.153499] WARNING: CPU: 0 PID: 4856 at drivers/media/common/videobuf2/videobuf2-core.c:1803 vb2_start_streaming+0xcb/0x160 [videobuf2_common] ... [ 1318.154551] Call Trace: [ 1318.154560] <TASK> [ 1318.154571] ? __warn.cold+0xb7/0x14a [ 1318.154591] ? vb2_start_streaming+0xcb/0x160 [videobuf2_common] [ 1318.154617] ? report_bug+0xe0/0x180 [ 1318.154640] ? handle_bug+0x5e/0xa0 [ 1318.154652] ? exc_invalid_op+0x14/0x70 [ 1318.154665] ? asm_exc_invalid_op+0x16/0x20 [ 1318.154697] ? vb2_start_streaming+0xcb/0x160 [videobuf2_common] [ 1318.154723] ? vb2_start_streaming+0x70/0x160 [videobuf2_common] [ 1318.154748] vb2_core_streamon+0xa2/0x100 [videobuf2_common] The sensor streamon call is the last thing that atomisp_start_streaming() does and it was failing to undo all of the previous steps in general. Refactor atomisp_stop_streaming() into an atomisp_stop_stream() helper and call that on sensor streamon failure to properly clean things up. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250505210008.152659-3-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-07-08media: atomisp: Move atomisp_stop_streaming() above atomisp_start_streaming()Hans de Goede1-74/+74
Move atomisp_stop_streaming() above atomisp_start_streaming(), this is a preparation patch for making atomisp_start_streaming() properly cleanup if starting the sensor stream fails. No functional change, only moving a block of code up. Signed-off-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250505210008.152659-2-hdegoede@redhat.com Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-05-05media: atomisp: Remove atomisp-mt9m114 driverHans de Goede4-3393/+0
The "media: atomisp: Add support for sensors with a separate ISP v4l2_subdev" combined with some pending drivers/media/i2c/mt9m114.c changes makes the atomisp work nicely with the standard V4L2 mt9m114.c driver, avoiding the need for the atomisp specific atomisp-mt9m114 driver. The normal driver actually works better since the atomisp-mt9m114 driver does not have working exposure control, leading to a much too dark image. Remove the no longer necessary atomisp-mt9m114 driver. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-05-05media: atomisp: Add support for sensors with a separate ISP v4l2_subdevHans de Goede4-11/+65
Some sensors have an ISP inside the sensor which the sensor driver models as a separate v4l2-subdev, like the mt9m114 sensor-driver does. Since the atomisp driver emulates a standard /dev/video# v4l2-device without requiring the application to be aware of media-controller centric /dev/video# devices this requires some special handling in the driver. Add support for this setup to the atomisp driver. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-05-05media: atomisp: Avoid deadlock with sensor subdevs with state_lock setHans de Goede1-2/+9
When a (sensor) v4l2_subdev has its state_lock member set to non NULL, then all v4l2_subdev_state-s for the sensor share the same lock. atomisp_init_sensor() calls v4l2_subdev_lock_and_get_active_state() and then later on also tries to lock a separate v4l2_subdev_state used for try calls (rather then changing the active state), while still holding the active state lock. Since this try v4l2_subdev_state shares a lock with the active state this results in a deadlock. Skip locking try_sd_state when sensor->state_lock is set to avoid this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-05-05media: atomisp: Rename camera to sensorHans de Goede6-45/+46
The camera v4l2_subdev pointer in struct atomisp_input_subdev points to an image sensor, rename camera to sensor to make this more clear. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-05-05media: atomisp: Remove compat ioctl32 header fileHardevsinh Palaniya2-248/+0
The atomisp_compat_ioctl32() function was deleted in commit b4c650f1af68 ("media: atomisp: remove compat_ioctl32 code"), so this header file is no longer needed. Additionally, the definition of atomisp_compat_ioctl32() in atomisp_ioctl.h is unused as well. Delete the declaration from the header. Signed-off-by: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20250421052804.11721-1-hardevsinh.palaniya@siliconsignals.io Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-05-05media: atomisp: gmin: Fix indentation to use TAB instead of spacesThomas Andreatta1-2/+2
Fix indentation to use TAB instead of spaces. Signed-off-by: Thomas Andreatta <thomasandreatta2000@gmail.com> Link: https://lore.kernel.org/r/20250426193033.483124-1-thomas.andreatta2000@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2025-05-05media: atomisp: gmin: Remove duplicate NULL testAbraham Samuel Adekunle1-1/+1
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL. Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested. Found by Coccinelle. Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com> Link: https://lore.kernel.org/r/26990d4a9d4419f9d4155a40595bc213acb671a0.1743685415.git.abrahamadekunle50@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>