summaryrefslogtreecommitdiffstats
path: root/drivers
Commit message (Collapse)AuthorAgeFilesLines
* media: dvb-frontends: mb86a16.c: always use the same error pathHans Verkuil2023-02-081-3/+6
| | | | | | | | | | If the message length was wrong, the dprintk() after the 'err' label was bypassed. Fix that, and fix a smatch warning at the same time: mb86a16.c:1514 mb86a16_send_diseqc_msg() warn: missing unwind goto? Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: i2c: ov7670: 0 instead of -EINVAL was returnedHans Verkuil2023-02-081-1/+1
| | | | | | | | | | | | | | If the media bus is unsupported, then return -EINVAL. Instead it returned 'ret' which happened to be 0. This fixes a smatch warning: ov7670.c:1843 ov7670_parse_dt() warn: missing error code? 'ret' Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Fixes: 01b8444828fc ("media: v4l2: i2c: ov7670: Implement OF mbus configuration") Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: ti: davinci: vpbe_display.c: return 0 instead of 'ret'.Hans Verkuil2023-02-081-1/+1
| | | | | | | | | | Since 'ret' is known to be 0, just return '0'. This fixes a smatch warning: vpbe_display.c:1152 vpbe_display_open() warn: missing error code? 'err' Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: "Lad, Prabhakar" <prabhakar.csengg@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: mediatek: vcodec/venc: return 0 instead of 'ret'.Hans Verkuil2023-02-081-2/+2
| | | | | | | | | | | Since 'ret' is known to be 0, just return '0'. This fixes a smatch warning: venc_h264_if.c:568 h264_encode_frame() warn: missing error code? 'ret' Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: Andrew-CT Chen <andrew-ct.chen@mediatek.com> Cc: Yunfei Dong <yunfei.dong@mediatek.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: mediatek: mdp3: replace return by goto for proper unwindHans Verkuil2023-02-081-1/+2
| | | | | | | | | | | | | An error was returned at one point without going through the goto label for proper unwinding. This fixes a smatch warning: mtk-mdp3-comp.c:1005 mdp_comp_config() warn: missing unwind goto? Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: Moudy Ho <moudy.ho@mediatek.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: dvb-frontends: drx39xyj: replace return with goto for proper unwindHans Verkuil2023-02-081-3/+6
| | | | | | | | | | | | | | In three places there was a return instead of a goto to the unwind code. This fixes three smatch warnings: drxj.c:9542 ctrl_get_qam_sig_quality() warn: missing unwind goto? drxj.c:10919 ctrl_set_standard() warn: missing unwind goto? drxj.c:11466 drxj_open() warn: missing unwind goto? Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: marvell: change return to goto for proper unwindHans Verkuil2023-02-081-1/+1
| | | | | | | | | | | | The probe function used 'goto out' everywhere, except in one place where it returned an error. That too should be a 'goto out'. This fixes a smatch warning: mmp-driver.c:257 mmpcam_probe() warn: missing unwind goto? Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: dvb-frontends: cxd2880: return 0 instead of 'ret'.Hans Verkuil2023-02-082-14/+14
| | | | | | | | | | | | | | | | | | | Since 'ret' is known to be 0, just return '0'. This fixes 10 smatch warnings: cxd2880_tnrdmd_dvbt.c:836 cxd2880_tnrdmd_dvbt_check_demod_lock() warn: missing error code? 'ret' cxd2880_tnrdmd_dvbt.c:841 cxd2880_tnrdmd_dvbt_check_demod_lock() warn: missing error code? 'ret' cxd2880_tnrdmd_dvbt.c:896 cxd2880_tnrdmd_dvbt_check_ts_lock() warn: missing error code? 'ret' cxd2880_tnrdmd_dvbt.c:901 cxd2880_tnrdmd_dvbt_check_ts_lock() warn: missing error code? 'ret' cxd2880_tnrdmd_dvbt.c:904 cxd2880_tnrdmd_dvbt_check_ts_lock() warn: missing error code? 'ret' cxd2880_tnrdmd_dvbt2.c:1027 cxd2880_tnrdmd_dvbt2_check_demod_lock() warn: missing error code? 'ret' cxd2880_tnrdmd_dvbt2.c:1032 cxd2880_tnrdmd_dvbt2_check_demod_lock() warn: missing error code? 'ret' cxd2880_tnrdmd_dvbt2.c:1087 cxd2880_tnrdmd_dvbt2_check_ts_lock() warn: missing error code? 'ret' cxd2880_tnrdmd_dvbt2.c:1092 cxd2880_tnrdmd_dvbt2_check_ts_lock() warn: missing error code? 'ret' cxd2880_tnrdmd_dvbt2.c:1095 cxd2880_tnrdmd_dvbt2_check_ts_lock() warn: missing error code? 'ret' Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: Yasunari Takiguchi <Yasunari.Takiguchi@sony.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: usb: dvb-usb-v2: af9015.c: return 0 instead of 'ret'.Hans Verkuil2023-02-081-2/+2
| | | | | | | | | | | Since 'ret' is known to be 0, just return '0'. This fixes two smatch warnings: af9015.c:1168 af9015_rc_query() warn: missing error code? 'ret' af9015.c:1177 af9015_rc_query() warn: missing error code? 'ret' Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: dvb-frontends: cxd2880: return 0 instead of 'ret'.Hans Verkuil2023-02-081-2/+2
| | | | | | | | | | | Since 'ret' is known to be 0, just return '0'. This fixes two smatch warnings: cxd2880_tnrdmd.c:2165 cxd2880_tnrdmd_check_internal_cpu_status() warn: missing error code? 'ret' cxd2880_tnrdmd.c:2169 cxd2880_tnrdmd_check_internal_cpu_status() warn: missing error code? 'ret' Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: Yasunari Takiguchi <Yasunari.Takiguchi@sony.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: i2c: s5c73m3: return 0 instead of 'ret'.Hans Verkuil2023-02-081-1/+1
| | | | | | | | | | Since 'ret' is known to be 0, just return '0'. This fixes a smatch warning: s5c73m3-core.c:439 __s5c73m3_s_stream() warn: missing error code? 'ret' Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: davinci/vpif.c: drop unnecessary castHans Verkuil2023-02-081-1/+1
| | | | | | | | | | | | | DEFINE_RES_IRQ_NAMED already casts to (struct resource), so no need to do it again. This fixes a sparse warning: vpif.c:483:20: warning: cast to non-scalar Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: "Lad, Prabhakar" <prabhakar.csengg@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: visl: make visl_qops staticHans Verkuil2023-02-081-1/+1
| | | | | | | | | | This struct can be static. This fixes a sparse warning: visl-video.c:690:22: warning: symbol 'visl_qops' was not declared. Should it be static? Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: pci: sh_css: Inline single invocation of macro STATS_ENABLED()Brent Pappas2023-02-081-4/+3
| | | | | | | | | | | | | | Inline the single invocation of the macro STATS_ENABLED(). The macro abstraction is not necessary because the logic behind it is only used once. Link: https://lore.kernel.org/r/20230120171408.16099-1-bpappas@pappasbrent.com Signed-off-by: Brent Pappas <bpappas@pappasbrent.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: pci: hive_isp_css_common: host: vmem: Replace SUBWORD macros ↵Brent Pappas2023-02-081-6/+14
| | | | | | | | | | | | | with functions Replace the macros SUBWORD() and INV_SUBWORD() with functions to comply with Linux coding style standards. Link: https://lore.kernel.org/r/20230120182625.23227-1-bpappas@pappasbrent.com Signed-off-by: Brent Pappas <bpappas@pappasbrent.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: pci: Replace bytes macros with functionsBrent Pappas2023-02-081-15/+23
| | | | | | | | | | | | | | | Replace the function-like macros FPNTBL_BYTES(), SCTBL_BYTES(), and MORPH_PLANE_BYTES() with functions to comply with Linux coding style standards. Replace multiplication with calls to array_size() and array3_size() to prevent accidental arithmetic overflow. Link: https://lore.kernel.org/r/20230118160739.26059-1-bpappas@pappasbrent.com Signed-off-by: Brent Pappas <bpappas@pappasbrent.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2722: Power on sensor from set_fmt() callbackHans de Goede2023-02-082-1/+13
| | | | | | | | | | | | | | | Depending on which order userspace makes various v4l2 calls, the sensor might still be powered down when set_fmt is called. What should really happen here is delay the writing of the mode-related registers till streaming is started, but for now use the same quick fix as the atomisp_ov2680 / atomisp_gc0310 code and call power_up() from set_fmt() in combination with keeping track of the power-state to avoid doing the power-up sequence twice. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2722: Don't take the input_lock for try_fmt calls.Hans de Goede2023-02-081-2/+1
| | | | | | | | | | On ov2722_set_fmt() calls with format->which == V4L2_SUBDEV_FORMAT_TRY, ov2722_set_fmt() does not talk to the sensor, so there is no need to lock the dev->input_lock mutex in this case. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2722: Fix GPIO1 polarityHans de Goede2023-02-081-4/+1
| | | | | | | | | | | | | | | | The comment claims the PWDN pin is active when pulled down in other words, it is /power-down so it needs to be driven high to get the sensor powered-up (not powered down) and flag is 1 when powering-up the sensor so the ! is wrong, drop it. This also matches with the schematics which I have which shows GPIO1 also enables a 3.3v line to the sensor-module which controls the privacy-LED and indeed before this patch the privacy LED was inverted from what it should be (and the sensor did not work). Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2722: Call atomisp_gmin_remove_subdev() on probe failureHans de Goede2023-02-081-0/+1
| | | | | | | | | | Call atomisp_gmin_remove_subdev() on probe failure to properly free the GPIOs and other resources acquired by the gmin_camera_platform_data() call earlier. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Switch over to ACPI powermanagementHans de Goede2023-02-082-181/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DSDT of all Windows BYT / CHT devices which I have seen has proper ACPI powermagement for the clk and regulators used by the sensors. So there is no need for the whole custom atomisp_gmin custom code to disable the ACPI pm and directly poke at the PMIC for this. Replace all the atomisp_gmin usage with using the new atomisp_register_sensor_no_gmin() / atomisp_unregister_subdev() helpers which allow registering a sensor with the atomisp code without using any of the atomisp_gmin power-management code. Note eventually these calls should be replaced by the standard v4l2_async_register_subdev_sensor() mechanism. But this first requires a bunch of work to the atomisp main code to make it set the necessary fwnodes up, similar to how drivers/media/pci/intel/ipu3/cio2-bridge.c does this. This has been tested on: -Trekstor Surftab duo W1 10.1, CHT, AXP288 PMIC, 2x ov2680 sensor -Asus T101HA, CHT, TI PMIC, 1x ov2680 sensor -MPMAN Converter 9, BYT, AXP288 PMIC, ov2680 back, gc0310 front sensor Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Use devm_kzalloc() for sensor data structHans de Goede2023-02-081-12/+4
| | | | | | | | | | | | | | | | | | | | Use devm_kzalloc() to allocate the sensor data struct. It is always free-ed as the last step of probe-error-exit or remove, so it can be devm-managed. This will make unwinding things easier when support is added to the ov2680 code to use standard GPIO APIs instead of the custom atomisp_gmin code. This also allows dropping the out_free label and use direct return on errors. This may seem like a functional change since the out_free label also did a v4l2_device_unregister_subdev() but at the 2 changed returns the device is not registered yet, so that always is a no-op and can be dropped. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Add dev local variable to probe()Hans de Goede2023-02-081-4/+5
| | | | | | | | | Add a dev local variable to probe(), to allow shortening &client->dev in various places, including further patches in this series. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: s/dev/sensor/Hans de Goede2023-02-081-37/+37
| | | | | | | | | | | | | | | | | | Using dev as name for variables pointing to struct ov2680_device is a bit unfortunate choice. All the recently added / rewritten code is already using sensor for this, replace the remaining usages of "struct ov2680_device *dev" with "struct ov2680_device *sensor". Note the power_up()/power_down() related functions are not changed as these will be removed in one of the next patches. No functional changes. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Add runtime-pm supportHans de Goede2023-02-082-22/+36
| | | | | | | | | | Add runtime-pm support. This is a preparation patch for letting ACPI deal with the regulators and clocks instead of the DIY code in atomisp_gmin_platform.c. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Delay power-on till streaming is startedHans de Goede2023-02-081-61/+41
| | | | | | | | | | | | Move the setting of the mode to stream on, this also allows delaying power-on till streaming is started. And drop the deprecated s_power callback since this now no long is necessary. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Cleanup includesHans de Goede2023-02-081-15/+5
| | | | | | | | Remove unused includes and sort the remaining ones alphabetically. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Consistently indent define valuesHans de Goede2023-02-081-18/+18
| | | | | | | | Use the same indentation level for all #define values. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Drop MAX_FMTS defineHans de Goede2023-02-082-3/+2
| | | | | | | | | The ov2680 only supports a single format, there is no need to use a define for this. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Remove unused data-types and defines from ov2680.hHans de Goede2023-02-081-60/+0
| | | | | | | | Remove a bunch of unused data-types and defines from ov2680.h. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Fix frame_size listHans de Goede2023-02-081-6/+2
| | | | | | | | | | | | | | | | | | | | | | 3 fixes for the framesize list: 1. Drop modes < 640x480, these are made by significant cropping, leading to such a small remainig field-of-view that they are not really usable 2. 1616x1082 is presumably intended to be 1600x1080 + 16 pixels padding in both dimensions, but the height is wrong. Change this to 1616x1096. 3. The 800x600 mode is missing the 16 pixels padding and 720x592 is missing 16 pixels padding in its width and the 720x576 base mode is a mode with non square pixels, while the sensor has square pixels. Replace both with 768x576 + 16 pixels padding -> 784x592 Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Drop struct ov2680_resolution / ov2680_res_previewHans de Goede2023-02-082-615/+19
| | | | | | | | | | | | | | | Drop struct ov2680_resolution and the ov2680_res_preview[] array, this is now only used in ov2680_enum_frame_size() and only the width + height are used there. Replace this with a new struct v4l2_frmsize_discrete ov2680_frame_sizes[] array. No functional changes. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Drop v4l2_find_nearest_size() call from set_fmt()Hans de Goede2023-02-081-7/+4
| | | | | | | | | | | | | Since we now calculate timings baded on the desired width and height, any width and height are valid as long as they don't exceed the sensor's dimensions. Drop the v4l2_find_nearest_size() call and instead clamp the requested width and height. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Fix ov2680_enum_frame_interval()Hans de Goede2023-02-081-11/+4
| | | | | | | | | | | | | | | | Fix and simplify ov2680_enum_frame_interval(), the index is not an index into ov2680_res_preview[], so using N_PREVIEW is wrong. Instead it is an index indexing the different framerates for the resolution specified in fie->width, fie->height. Since the ov2680 code only supports a single fixed 30 fps, index must always be 0 and we don't need to check the other fie input values. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Drop unused res member from struct ov2680_deviceHans de Goede2023-02-082-6/+0
| | | | | | | | | The res member of struct ov2680_device isn't read anywhere anymore, drop it. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Use defines for fps, lines-per-frame and skip-framesHans de Goede2023-02-082-12/+6
| | | | | | | | | | | | | | | | | The fps, lines-per-frame and skip-frames values are the same for all resolutions, use defines for these. The ov2680_res_preview[] incorrectly sets fps to 60 for some low-res modes, this is incorrect with the current fixed (resolution independent) lines-per-frame value. Note this not drop the now no longer used fps, lines-per-frame and skip-frames struct ov2680_resolution members. The entire struct is going away in the next patches so that would just cause unnecessary changes. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Make setting the modes algorithm basedHans de Goede2023-02-082-14/+158
| | | | | | | | | | | Instead of using a long fixed register settings list for each resolution, calculate the register settings based on the requested width + height. This will allow future enhancements like adding hblank and vblank controls and adding selection support. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Fix window settings and enable window for all ↵Hans de Goede2023-02-081-38/+38
| | | | | | | | | | | | | | | | | | | | | | | | | resolutions By default the ov2680 automatically sets the window to match the outputsize and automatically adjusts it to keep the bayer pattern stable when enabling hflip/vflip. This does not work for the 1616x1216 mode because there is no room to adjust the window there. To make flipping work in the 1616 wide modes the register lists for those modes set bit 0 of 0x5708 (manual_win_en) to 1 and ov2680_set_bayer_order() updates the bayer-order on the pad to match. But ov2680_set_bayer_order() is always called, so when enabling flipping on modes with a width of less then 1616 now results in the wrong bayer order being reported on the pad since the sensor is auto-adjusting the window in this case. Specify the correct (== output-size) window-size in all resolutions register-list and always set the manual_win_en bit, so that the bayer order is changed on hflip/vflip enable on all resolutions. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Add test pattern controlHans de Goede2023-02-082-0/+36
| | | | | | | | | Add a test pattern control. This is a 1:1 copy of the test pattern control in the main drivers/media/i2c/ov2680.c driver. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Add exposure and gain controlsHans de Goede2023-02-082-10/+26
| | | | | | | | | | | | Add exposure and gain controls. This allows controlling the exposure and gain through standard v4l2 IOCTLs. Note the register defines for the exposure and gain registers are renamed to match the datasheet. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Drop custom ATOMISP_IOC_S_EXPOSURE supportHans de Goede2023-02-082-210/+2
| | | | | | | | | | | | Exposure and gain control should use standard v4l2 controls, not a custom ioctl. The next patch in this series will re-add support as standard controls, this is split into 2 patches for easier reviewing. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Rework flip ctrlsHans de Goede2023-02-082-164/+155
| | | | | | | | | | | | | | | Rework the flip ctrls to be more like those of mainline (non staging) drivers. This is modelled after the main ov2680 and ov5693 drivers. This also introduces __ov2680_get_pad_format() to make the ov2680 code more compliant with the mainline v4l2-subdev APIs. Note the OV2680_FLIP_REG and OV2680_MIRROR_REG defines are renamed to OV2680_REG_FORMAT1 and OV2680_REG_FORMAT2 to match the datasheet. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: ov2680: Use the new ov_16bit_addr_reg_helpers.hHans de Goede2023-02-082-101/+25
| | | | | | | | | Use the new ov_16bit_addr_reg_helpers.h instead of duplicating the ovxxxx sensor I2C register access helpers found in many different sensor drivers. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: Properly initialize function field of media-entity linksHans de Goede2023-02-083-3/+3
| | | | | | | | | | | | | | | | | Don't use MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN to initialize the function field of various media-entity links. This fixes the following warnings showing up in dmesg: atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port0 was not initialized! atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port1 was not initialized! atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port2 was not initialized! atomisp-isp2 0000:00:03.0: Entity type for entity tpg_subdev was not initialized! atomisp-isp2 0000:00:03.0: Entity type for entity ATOMISP_SUBDEV_0 was not initialized! atomisp-isp2 0000:00:03.0: Entity type for entity ATOMISP_SUBDEV_1 was not initialized! Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: Remove csi2_link_setup()Hans de Goede2023-02-082-44/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looking at csi2_link_setup(), this function can never work, it does a switch-case like this: switch (local->index | is_media_entity_v4l2_subdev(remote->entity)) with cases like this: case ATOMISP_SUBDEV_PAD_SOURCE | MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN where ATOMISP_SUBDEV_PAD_SOURCE matches an index (0-1) and MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN is 0x00020000, but is_media_entity_v4l2_subdev(remote->entity) does not return MEDIA_ENT_F_* values, it return a bool, so 0 or 1 which means that non of the cases can ever match the input value. Looking at the rest of the function all it ever does (if it would actually hit one of the cases) is set the atomisp_mipi_csi2_device struct's output member. And checking the rest of the atomisp code that member is never read. Also userspace does not actually setup media-controller links when using the atomisp /dev/video$ nodes since all the links are fixed. So csi2_link_setup() never runs. Remove the unnecessary and broken csi2_link_setup() function and also remove the unused atomisp_mipi_csi2_device struct's output member. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: Remove isp_subdev_link_setup()Hans de Goede2023-02-082-92/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looking at isp_subdev_link_setup(), this function can never work, it does a switch-case like this: switch (local->index | is_media_entity_v4l2_subdev(remote->entity)) with cases like this: case ATOMISP_SUBDEV_PAD_SINK | MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN where ATOMISP_SUBDEV_PAD_SINK matches an index (0-4) and MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN is 0x00020000, but is_media_entity_v4l2_subdev(remote->entity) does not return MEDIA_ENT_F_* values, it return a bool, so 0 or 1 which means that non of the cases can ever match the input value. Looking at the rest of the function all it ever does (if it would actually hit one of the cases) is set the atomisp_sub_device struct's input member. And checking the rest of the atomisp code that member is never read. Also userspace does not actually setup media-controller links when using the atomisp /dev/video$ nodes since all the links are fixed. So isp_subdev_link_setup() never runs. Remove the unnecessary and broken isp_subdev_link_setup() function and also remove the unused atomisp_sub_device struct's input member. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: Put sensor ACPI devices in D3 before disable ACPI ↵Hans de Goede2023-02-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | power-resources The device core will call ACPI to turn the device (i2c_client) for a sensor on / put it in D0 before calling its probe() method. This takes a reference on all of the ACPI power-resources belonging to the device. Since the atomisp_gmin_platform code disables ACPI power-resource management and does its own pm, this reference never gets released. This is a problem for ACPI power-resources which are shared with other devices since those now never get turned off again (nor back on again). Explicitly put the device in D3 before disabling the ACPI power-resource management. Note that atomisp_register_i2c_module() runs near the end of the sensor driver's probe() function, after the driver is done with probing the hw. So the power-resouces (the same resources as directly controlled by the atomisp platform code) getting turned off (a second time, as they are already off) is not a problem. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: Stop overriding padding w/h to 12 on BYTHans de Goede2023-02-081-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | atomisp_set_fmt() first does: v4l2_fill_mbus_format(&vformat.format, ...); vformat.format.height += padding_h; vformat.format.width += padding_w; ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, pad, set_fmt, NULL, &vformat); if (ret) return ret; f->fmt.pix.width = vformat.format.width - padding_w; f->fmt.pix.height = vformat.format.height - padding_h; this happens with the original padding w/h = 16 values and then later on it calls: ret = atomisp_set_fmt_to_snr(vdev, &s_fmt, f->fmt.pix.pixelformat, padding_w, padding_h, dvs_env_w, dvs_env_h); Which repeats the above structure. If at that point padding w/h are changed to 12 then it will now request a different output-size of the sensor driver. The sensor drivers so far have actually been ignoring this since they use v4l2_find_nearest_size() on a fixed resolution list and the nearest resolution will be the one from the earlier calls where padding w/h was 16. But there really is no reason for sensor drivers to use a fixed resolution list. They make lower resolutions using cropping so they can make any resolution as long as width/height are even numbers. Dropping the fixed-resolution list limit from sensors on BYT results in trying to start streaming failing because the resolution set to the sensor now no longer matches with the resolution used during the initial part of the configuration done by atomisp_set_fmt(). Drop the BYT specific overriding of the padding_w/h to 12, so that the padding in the first and second s_fmt calls made to the sensor matches, to fix stream start failing when the fixed resolution list is dropped. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: Drop ffmt local var from atomisp_set_fmt()Hans de Goede2023-02-081-6/+5
| | | | | | | | | ffmt is a local variable pointing to a substruct of another local variable which really just makes the code harder to read / follow, so drop it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
* media: atomisp: Add atomisp_register_sensor_no_gmin() helperHans de Goede2023-02-082-0/+65
| | | | | | | | | | | | | | | | The DSDT of all Windows BYT / CHT devices which I have seen has proper ACPI powermagement for the clk and regulators used by the sensors. So there is no need for the whole custom atomisp_gmin custom code to disable the ACPI pm and directly poke at the PMIC for this. Add new atomisp_register_sensor_no_gmin() + atomisp_unregister_subdev() helpers which allow registering a sensor with the atomisp code without using any of the atomisp_gmin power-management code. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>