Hans Verkuil [Wed, 24 May 2023 12:11:47 +0000 (13:11 +0100)]
media: platform: mediatek: vpu: fix NULL ptr dereference
If pdev is NULL, then it is still dereferenced.
This fixes this smatch warning:
drivers/media/platform/mediatek/vpu/mtk_vpu.c:570 vpu_load_firmware() warn: address of NULL pointer 'pdev'
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans Verkuil [Wed, 24 May 2023 12:11:46 +0000 (13:11 +0100)]
media: platform: renesas-ceu: drop buf NULL check
Since start_streaming is only called if there are at least two
buffers queued, the ceudev->capture list will never be empty, so
the check whether there are no buffers can be dropped.
Note that the '!buf' check was wrong in any case, if we wanted to
check for an empty list it should have used list_empty().
This fixes this smatch warning:
drivers/media/platform/renesas/renesas-ceu.c:705 ceu_start_streaming() warn: can 'buf' even be NULL?
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans Verkuil [Wed, 24 May 2023 12:11:45 +0000 (13:11 +0100)]
media: usb: as102: drop as102_dev NULL check
Fixes this smatch warning:
drivers/media/usb/as102/as102_usb_drv.c:306 as102_usb_release() warn: can 'as102_dev' even be NULL?
And indeed, as102_dev can never be NULL, so just drop the NULL check.
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans Verkuil [Wed, 24 May 2023 12:11:44 +0000 (13:11 +0100)]
media: rockchip: rga: fix clock cleanup
Fix this smatch warning:
drivers/media/platform/rockchip/rga/rga.c:734 rga_enable_clocks() warn: 'rga->sclk' from clk_prepare_enable() not released on lines: 734.
The reason is that aclk should be disabled/unprepared before
sclk, instead of the other way around.
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Jacob Chen <jacob-chen@iotwrt.com>
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Tue, 6 Jun 2023 13:31:36 +0000 (14:31 +0100)]
media: atomisp: csi2-bridge: Add support for setting "clock-" and "link-frequencies" props
Some standard v4l2 sensor drivers from drivers/media/i2c expect a
"clock-frequency" property on the device indicating the frequency
of the extclk for the sensor. Example of such drivers are the
ov2680 and ov5693 drivers.
The standard ov5693 sensor also expects a "link-frequencies" property.
Add support for setting both properties.
Note the "clock-frequency" prop is added before the "rotation" prop while
the "link-frequencies" are added at the end to match the ipu3 cio2-bridge
code from which this is derived.
Link: https://lore.kernel.org/r/20230606133136.23619-1-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 4 Jun 2023 16:14:06 +0000 (17:14 +0100)]
media: atomisp: Add testing instructions to TODO file
Testing the atomisp can be a bit tricky. The BYT/CHT CPUs are not
very powerful so some apps like camorama cannot run at full FPS.
Add instructions for how to test with gstreamer which does
runs at full FPS without issues.
Link: https://lore.kernel.org/r/20230604161406.69369-6-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 4 Jun 2023 16:14:05 +0000 (17:14 +0100)]
media: atomisp: ov2680: Rename unknown/0x370a to sensor_ctrl_0a
The data sheets say the registers at offset 0x3700 - 0x373f are
"sensor control" registers rename the unknown variable in
ov2680_set_mode() to sensor_ctrl_0a and add
a OV2680_REG_SENSOR_CTRL_0A define.
Link: https://lore.kernel.org/r/20230604161406.69369-5-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 4 Jun 2023 16:14:04 +0000 (17:14 +0100)]
media: atomisp: ov2680: Remove unnecessary registers from ov2680_global_setting[]
Many of the values in ov2680_global_setting[] match the default/reset
register value for the ov2680 sensor (verified with both datasheet
and actual hw) so they are no-ops.
And there are also a couple of others which are later overwritten
by ctrls or by ov2680_set_mode().
Remove all the unnecessary entries and add annotations to
the remaining entries documenting what they change
(in so far as things are documented in the datasheet).
This also removes the double writing of OV2680_REG_SOFT_RESET in
ov2680_init_registers() (one direct write, one in ov2680_global_setting[])
instead add a short sleep after the first write to give the sensor
time to reset.
Link: https://lore.kernel.org/r/20230604161406.69369-4-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 4 Jun 2023 16:14:03 +0000 (17:14 +0100)]
media: atomisp: ov2680: Stop using half pixelclock for binned modes
Stop using half pixelclock for binned modes this fixes:
1. The exposure being twice as high for binned mods (due to the half clk)
2. The framerate being 15 fps instead of 30 fps
The original code with fixed per mode register lists did use half pixel
clk, but this should be combined with using half for the VTS value too.
Using half VTS fixes the framerate issue, but this has the undesired
side-effect of change the exposure ctrl range (half the range, double
the amount of exposure per step).
Link: https://lore.kernel.org/r/20230604161406.69369-3-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 4 Jun 2023 16:14:02 +0000 (17:14 +0100)]
media: atomisp: Stop resetting selected input to 0 between /dev/video# opens
No other V4L2 driver resets the selected input (front cam or back cam
selected in case of the atomisp).
Stop resetting selected input to 0 between /dev/video# opens.
This allows e.g. using v4l2-ctl -i to switch the input before starting
another app, which is useful since most apps don't support selecting
the input.
Note more in general the whole resetting of a bunch of internal
state from the open fop needs to be removed there to allow multiple
opens of /dev/video# for full v4l2 API compliance.
Link: https://lore.kernel.org/r/20230604161406.69369-2-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 1 Jun 2023 14:58:58 +0000 (15:58 +0100)]
media: atomisp: Fix binning check in atomisp_set_crop()
The fmt / size passed to atomisp_set_crop() includes padding,
so the binning check should be against 1/2 of the native rect.
of the sensor, rather then 1/2 of the active rect.
This fixes binning not being used when using e.g. 800x600 on
a 1600x1200 sensor leading to a very small field of view.
Link: https://lore.kernel.org/r/20230601145858.59652-4-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 1 Jun 2023 14:58:57 +0000 (15:58 +0100)]
media: atomisp: Make atomisp_enum_framesizes_crop() check resolution fits with padding
Now that atomisp_get_padding() takes minimum padding requirements
on BYT/ISP2400 into account, it is possible for a resolution which
fits in the active area of the sensor to not fit in the native area
once padding is added.
For example on the ov2680 which has a native resolution of 1616x1216
the max active resolution of 1600x1200 leaves 16x16 for padding which
meets the worst-case minimum padding requirement of 14x14 on BYT.
But after binning we are left with an native area of 808x608 and
an active area of 800x600. This leaves 8x8 for padding which is not
enough. So on BYT 800x600 is not a valid resolution (it could be
made by lots of cropping without binning but then the remaining
field of view is no good).
Modify atomisp_enum_framesizes_crop() to check the resolution +
padding fits in the native rectangle, removing 800x600 from
the list of valid modes on BYT.
Link: https://lore.kernel.org/r/20230601145858.59652-3-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 1 Jun 2023 14:58:56 +0000 (15:58 +0100)]
media: atomisp: Take minimum padding requirement on BYT/ISP2400 into account
The main binary for the pipeline on BYT/ISP2400 has its
ia_css_binary_info.pipeline.left_cropping and .top_cropping fields
set to 12. So a minimum padding of 12 is required.
And for certain bayer-orders additional width / height padding is
necessary so that the ISP crop rectangle for the raw sensor data
can be used to change the bayer-order to the fixed bayer-order
supported by the debayer block.
Without the minmum required padding ia_css_ifmtr_configure() will fail
inside ifmtr_input_start_line() and/or ifmtr_start_column() because
it cannot set the ISP crop rectangle for the raw sensor data.
Fix this by making atomisp_get_padding() take the minimum padding
requirements into account on BYT/ISP2400 (CHT/ISP2401 does not seem to
need this).
Link: https://lore.kernel.org/r/20230601145858.59652-2-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:41 +0000 (11:37 +0100)]
media: atomisp: csi2-bridge: Set PMC clk-rate for sensors to 19.2 MHz
The ACPI code takes care of enabling/disabling the PMC clk(s) for
the sensors as necessary based on the runtime-pm state of the sensor.
But the GMIN code this replaces also set the clk-rate of the PMC clk
to 19.2 MHz. At least on BYT devices the PMC clks may come up running
at 25 MHz instead of the expected 19.2 MHz.
Ensure the sensor clk also runs at the expected 19.2 MHz for sensors
using v4l2-async probing by explicitly setting it to 19.2 MHz when
enumerating sensors in atomisp_csi2_bridge.c.
Link: https://lore.kernel.org/r/20230529103741.11904-22-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:40 +0000 (11:37 +0100)]
media: atomisp: Add enum_framesizes function for sensors with selection / crop support
Some sensor drivers with crop support (e.g. the ov5693 driver) only
return the current crop rectangle + 1/2 (binning) of the current crop
rectangle when calling their enum_frame_sizes op.
This causes 2 issues:
1. Atomisp sets to the crop area to include the padding, where as
the enum_framesizes ioctl should return values without padding.
2. With cropping a lot more standard resolutions are possible then
just these 2 and many apps limit the list given to the end user
to the list returned by enum_framesizes.
Add an alternative enum_framesizes function for sensors which support
cropping to fix both issues.
Link: https://lore.kernel.org/r/20230529103741.11904-21-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:39 +0000 (11:37 +0100)]
media: atomisp: Set crop before setting fmt
Some drivers which implement selections/crop only allow setting the format
with and height to either the crop rectangle width and height or to half
the crop rectangle width and height (binning). An example of such
a driver is the standard v4l2 ov5693 driver.
First set the crop rectangle to match the requested format
when trying or setting the sensor format, to match these drivers
expectations.
Link: https://lore.kernel.org/r/20230529103741.11904-20-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:38 +0000 (11:37 +0100)]
media: atomisp: Use selection API info to determine sensor padding
Using the selection / crop info to determine the padding values
to use with a specific resolution on specific sensor.
This allows e.g. automatically halving the padding when using
the max binned resolution and also ensures the right amount
of padding is used on models with 2 sensors with different
padding requirements.
Link: https://lore.kernel.org/r/20230529103741.11904-19-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:37 +0000 (11:37 +0100)]
media: atomisp: Make atomisp_init_sensor() check if the sensor supports binning
Make atomisp_init_sensor() check if the sensor supports binning.
This is a preparation patch for using the selection / crop support
to determine the padding values to use with a specific sensor.
Link: https://lore.kernel.org/r/20230529103741.11904-18-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:36 +0000 (11:37 +0100)]
media: atomisp: Pass MEDIA_BUS_FMT_* code when calling enum_frame_size pad-op
A sensor driver's enum_frame_size pad-op may return -EINVAL when
v4l2_subdev_frame_size_enum.code is not set to a supported
MEDIA_BUS_FMT_* code.
Make atomisp_init_sensor() get the sensor's MEDIA_BUS_FMT_* code and
pass this when calling the enum_frame_size pad-op.
Link: https://lore.kernel.org/r/20230529103741.11904-17-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:35 +0000 (11:37 +0100)]
media: atomisp: Add support for sensors which implement selection API / cropping
Sensor drivers which implement set_selection V4L2_SEL_TGT_CROP expect
v4l2_subdev_state.pads[pad].try_crop to have valid contents when calling
set_fmt with which == V4L2_SUBDEV_FORMAT_TRY since the crop-rectangle
may influence the available image size.
Just passing an uninitalized struct v4l2_subdev_pad_config from
the stack to set_fmt with which == V4L2_SUBDEV_FORMAT_TRY will result
in wrong results with such drivers.
Store a per sensor v4l2_subdev_pad_config and add a new
atomisp_init_sensor_crop() function to initialize this before
registering /dev/* nodes with userspace.
Sensor drivers which implement the selection API will allow
the atomisp to properly deal with the extra padding the ISP wants
on a per sensor basis instead of hardcoding this.
atomisp_init_sensor_crop() stores the native and active rects
of the sensor in preparation for using these for this.
Link: https://lore.kernel.org/r/20230529103741.11904-16-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:34 +0000 (11:37 +0100)]
media: atomisp: Refactor atomisp_try_fmt() / atomisp_set_fmt()
There are a number of bugs in atomisp_try_fmt_cap() and atomisp_set_fmt():
1. atomisp_try_fmt_cap() uses atomisp_adjust_fmt() which adds the sensor
padding to the width passed to atomisp_adjust_fmt() to calculate
bytesperline. This is buggy for 2 reasons:
a) The width passed to atomisp_adjust_fmt() already contains
the sensor padding.
b) The fmt returned by atomisp_try_fmt_cap() is the fmt outputted by
the ISP and the sensor padding applies to the input side of the ISP
not the output side. The output side of the ISP has its own padding /
pitch requirements which have nothing to do with the sensor.
Both these issues are fixed in this refactor by switching to
ia_css_frame_pad_width() to calculate the padding.
2. atomisp_set_fmt() takes the passed in bytesperline value without
doing any validation on it and then passes this unchecked value to
the configure_output() callback.
If bytesperline converted to pixels is > 1920 ia_css_binary_find()
will fail to find a valid binary for the preview pipeline triggering
a dump_stack_lvl() call inside ia_css_binary_find() and causing
atomisp_set_fmt() to fail.
This is fixed by making atomisp_set_fmt() call atomisp_try_fmt()
first which we override the userspace specified bytesperline with
the correct value.
Besides this bug there is also a bunch of weirdness and a lot of
duplication in the code:
1. atomisp_try_fmt_cap() adds the sensor padding itself but then
it gets substracted again in atomisp_adjust_fmt() not doing
the addition + substraction in the same place makes the code hard
to follow (weirdness).
2. atomisp_set_fmt() starts with basically an atomisp_try_fmt() call,
except that the only atomisp_try_fmt() caller: atomisp_try_fmt_cap()
adds the sensor padding itself rather than letting atomisp_try_fmt()
do this (duplication).
3. Both atomisp_try_fmt_cap() and atomisp_set_fmt() contain code to
lookup the bridge-format matching the requested pixelformat and
both will fallback to YUV420 if this is not set (duplication).
4. Both atomisp_try_fmt_cap() and atomisp_set_fmt() contain code to
fill in the passed in v4l2_pix_format struct (duplication).
Cleanup all of this (and fix the bugs mentioned above) by:
1. Adding a new atomisp_fill_pix_format() helper which properly uses
ia_css_frame_pad_width() to calculate bytesperline.
2. Move all sensor padding handling to atomisp_try_fmt() and
make atomisp_try_fmt() fill the passed in v4l2_pix_format struct.
3. This reduces atomisp_try_fmt_cap() to just a small wrapper around
atomisp_try_fmt().
4. Replace the DIY try_fmt code at the beginning of atomisp_set_fmt()
with atomisp_try_fmt(), this will also override/fix the bytersperline
passed by userspace.
5. Replace the DIY v4l2_pix_format filling at the end of atomisp_set_fmt()
with atomisp_fill_pix_format().
Link: https://lore.kernel.org/r/20230529103741.11904-15-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:33 +0000 (11:37 +0100)]
media: atomisp: Add ia_css_frame_pad_width() helper function
Factor the code to go from width to a properly aligned pitch out of
ia_css_frame_info_set_width().
This is a preparation patch to fix try_fmt() calls returning a bogus
bytesperline value.
Link: https://lore.kernel.org/r/20230529103741.11904-14-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:32 +0000 (11:37 +0100)]
media: atomisp: Add input helper variable for isp->asd->inputs[asd->input_curr]
Passing 'isp->asd->inputs[asd->input_curr].foo' as argument to
various function calls is rather long.
Add a local input helper variable for this, so that the function
calls will fit on one line.
Link: https://lore.kernel.org/r/20230529103741.11904-13-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:31 +0000 (11:37 +0100)]
media: atomisp: Remove bogus fh use from atomisp_set_fmt*()
atomisp_set_fmt*() use a local v4l2_subdev_fh declared on the stack,
specifically they use fh.state which is never initialized so when
passing fh.state to atomisp_subdev_set_ffmt() / to
atomisp_subdev_set_selection() these functions are passing random
stack contents as a pointer.
The reason this works is because when the which parameter is
V4L2_SUBDEV_FORMAT_ACTIVE the passed in state is not used.
Remove the bogus fh usage and just pass NULL as state.
Link: https://lore.kernel.org/r/20230529103741.11904-12-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:30 +0000 (11:37 +0100)]
media: atomisp: Add target validation to atomisp_subdev_set_selection()
As the 2 comments in the function already say both the sink and the source
pads only support setting the selection for 1 target:
/* Only crop target supported on sink pad. */
/* Only compose target is supported on source pads. */
Validate that the passed in target actually matches these expectations.
Link: https://lore.kernel.org/r/20230529103741.11904-11-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:29 +0000 (11:37 +0100)]
media: atomisp: Simplify atomisp_subdev_set_selection() calls in atomisp_set_fmt()
With the atomisp_subdev_set_selection(sink-pad, V4L2_SEL_TGT_CROP, rect)
calls dropped. The first and last compount code blocks of the 3 code blocks
in the if (...) {} else if (...) {} else {} code setting the source-pad
V4L2_SEL_TGT_COMPOSE selection are the same.
The both set V4L2_SEL_TGT_COMPOSE to a rectangle with the same dimensions
as f->fmt.pix.height.
Remove the else {} block at the end, drop the second if and prepend
the first if condition with "!second-if-condition ||" to remove
the code duplication.
Link: https://lore.kernel.org/r/20230529103741.11904-10-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:28 +0000 (11:37 +0100)]
media: atomisp: Remove redundant atomisp_subdev_set_selection() calls from atomisp_set_fmt()
atomisp_subdev_set_selection(sink-pad, V4L2_SEL_TGT_CROP, rect)
ignores the passed in rect, using the width and height from the last
atomisp_subdev_set_ffmt(ATOMISP_SUBDEV_PAD_SINK, ffmt) call instead.
The atomisp_subdev_set_ffmt() call done by atomisp_set_fmt_to_snr()
already propagates the sink ffmt changes to V4L2_SEL_TGT_CROP
(this is what allows atomisp_set_fmt() to get the isp_sink_crop in
the first place).
Remove the redundant atomisp_subdev_set_selection(sink-pad, ...)
calls.
Note the removed aspect ratio correction in the last else block is
is already done by atomisp_subdev_set_selection() itself when
setting V4L2_SEL_TGT_COMPOSE on the source-pad.
Link: https://lore.kernel.org/r/20230529103741.11904-9-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:27 +0000 (11:37 +0100)]
media: atomisp: Remove a bunch of sensor related custom IOCTLs
Remove a bunch of sensor related custom IOCTLs because:
1. They are custom IOCTLs and all custom IOCTLs should be removed
2. Userspace should directly talk to the sensor v4l2-subdev, rather
then relying on ioctl-s on the output /dev/video# node to pass
through ioctl-s to the senor
3. Some of these rely on the atomisp specific camera_mipi_info struct
which is going away as we are switching to using standard v4l2
sensor drivers
4. In the case of ATOMISP_IOC_S_EXPOSURE_WINDOW this was using the
v4l2-subdev set_selection API in an undocumented atomisp custom way
Link: https://lore.kernel.org/r/20230529103741.11904-8-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:26 +0000 (11:37 +0100)]
media: atomisp: ov2680: Implement selection support
Implement selection support. Modelled after ov5693 selection support,
but allow setting sizes smaller than crop-size through set_fmt since
that was already allowed.
Link: https://lore.kernel.org/r/20230529103741.11904-7-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:25 +0000 (11:37 +0100)]
media: atomisp: ov2680: Add init_cfg pad-op
Having an init_cfg to initialize the passed in subdev-state is
important to make which == V4L2_SUBDEV_FORMAT_TRY ops work when
userspace is talking to a /dev/v4l2-subdev# node.
Copy the ov2680_init_cfg() from the standard drivers/media/i2c/ov2680.c
driver.
This is esp. relevant once support for cropping is added where
the v4l2_subdev_state.pads[pad].try_crop rectangle needs to be set
correctly for set_fmt which == V4L2_SUBDEV_FORMAT_TRY calls to work.
Link: https://lore.kernel.org/r/20230529103741.11904-6-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:24 +0000 (11:37 +0100)]
media: atomisp: ov2680: Add missing ov2680_calc_mode() call to probe()
Call ov2680_calc_mode() from probe() instead of relying on userspace
to make at least one s_fmt call to fill the mode parameters.
Link: https://lore.kernel.org/r/20230529103741.11904-5-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:23 +0000 (11:37 +0100)]
media: atomisp: ov2680: s/input_lock/lock/
s/input_lock/lock/ lock is used by the generic drivers/media/i2c/ov2680.c
driver. Bring the atomisp ov2680 code inline to make it easier to port
changes between the two, with the end goal of getting rid of
the atomisp specific version.
Link: https://lore.kernel.org/r/20230529103741.11904-4-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:22 +0000 (11:37 +0100)]
media: atomisp: ov2680: s/ov2680_device/ov2680_dev/
s/ov2680_device/ov2680_dev/ ov2680_dev is used by the generic
drivers/media/i2c/ov2680.c driver. Bring the atomisp ov2680 code
inline to make it easier to port changes between the two,
with the end goal of getting rid of the atomisp specific version.
Link: https://lore.kernel.org/r/20230529103741.11904-3-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 29 May 2023 10:37:21 +0000 (11:37 +0100)]
media: atomisp: Update TODO
A lot of work has been done on the atomisp driver lately.
Rewrite the TODO file to drop all the already fixed items:
* Moved to videobuf2 + fixed mmap support
* Whole bunch of v4l2 API fixes making more apps work
* v4l2-async sensor probing support
* pm-runtime support (for some sensor drivers at least)
* buffer MM code was cleaned up / replaced when moving the videobuf2
And add a new TODO list (retaining some of the old items) split
into items which absolutely must be fixed before the driver can
be moved out of staging:
1. Conflicting hw-ids with regular sensor drivers
2. Private userspace API stuff
As well as a list of items which also definitely needs to be fixed
but which could also be fixed after moving the driver out of staging.
Link: https://lore.kernel.org/r/20230529103741.11904-2-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sat, 27 May 2023 15:38:12 +0000 (16:38 +0100)]
media: atomisp: Fix buffer overrun in gmin_get_var_int()
Not all functions used in gmin_get_var_int() update len to the actual
length of the returned string. So len may still have its initial value
of the length of val[] when "val[len] = 0;" is run to ensure 0 termination.
If this happens we end up writing one beyond the bounds of val[], fix this.
Note this is a quick fix for this since the entirety of
atomisp_gmin_platform.c will be removed once all atomisp sensor
drivers have been moved over to runtime-pm + v4l2-async device
registration.
Closes: https://lore.kernel.org/linux-media/
26f37e19-c240-4d77-831d-
ef3f1a4dd51d@kili.mountain/
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dan Carpenter [Fri, 26 May 2023 11:53:23 +0000 (12:53 +0100)]
media: atomisp: gmin_platform: fix out_len in gmin_get_config_dsm_var()
Ideally, strlen(cur->string.pointer) and strlen(out) would be the same.
But this code is using strscpy() to avoid a potential buffer overflow.
So in the same way we should take the strlen() of the smaller string to
avoid a buffer overflow in the caller, gmin_get_var_int().
Link: https://lore.kernel.org/r/26124bcd-8132-4483-9d67-225c87d424e8@kili.mountain
Fixes:
387041cda44e ("media: atomisp: improve sensor detection code to use _DSM table")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 25 May 2023 19:00:59 +0000 (20:00 +0100)]
media: atomisp: Drop v4l2_get_acpi_sensor_info() function
Drop v4l2_get_acpi_sensor_info() the 2 sensor drivers which were
using this have both been converted to v4l2-async probing, relying
on the atomisp_csi2_bridge.c code to add the GPIO mappings instead.
Link: https://lore.kernel.org/r/20230525190100.130010-5-hdegoede@redhat.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>
Hans de Goede [Thu, 25 May 2023 19:00:58 +0000 (20:00 +0100)]
media: atomisp: gc0310: Turn into standard v4l2 sensor driver
Switch the atomisp-gc0310 driver to v4l2 async device registration.
After this change this driver no longer depends on
atomisp_gmin_platform and all atomisp-isms are gone.
Link: https://lore.kernel.org/r/20230525190100.130010-4-hdegoede@redhat.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>
Hans de Goede [Thu, 25 May 2023 19:00:57 +0000 (20:00 +0100)]
media: atomisp: ov2680: Turn into standard v4l2 sensor driver
Turn the atomisp-ov2680 driver into a standard v4l2 sensor driver:
1. Stop filling camera_mipi_info
2. Stop calling v4l2_get_acpi_sensor_info() this will be done by
atomisp_csi2_bridge_parse_firmware() now
3. Switch to v4l2 async device registration
After this change this driver no longer depends on
atomisp_gmin_platform and all atomisp-isms are gone.
While at it, also add missing mutex_destroy() to ov2680_remove().
Link: https://lore.kernel.org/r/20230525190100.130010-3-hdegoede@redhat.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>
Hans de Goede [Thu, 25 May 2023 19:00:56 +0000 (20:00 +0100)]
media: atomisp: Add support for v4l2-async sensor registration
Add support for using v4l2-async sensor registration.
This has been tested with both the gc0310 and the ov2680 sensor drivers.
Drivers must add the ACPI HIDs they match on to the supported_sensors[]
array in the same commit as that they are converted to
v4l2_async_register_subdev_sensor().
Sensor drivers also must check they have a fwnode graph endpoint and return
-EPROBE_DEFER from probe() if there is no endpoint yet. This guarantees
that the GPIO mappings are in place before the driver tries to get GPIOs.
For now it also is still possible to use the old atomisp_gmin_platform
based sensor drivers. This is mainly intended for testing while moving
other sensor drivers over to runtime-pm + v4l2-async.
Link: https://lore.kernel.org/r/20230525190100.130010-2-hdegoede@redhat.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>
Hans Verkuil [Wed, 24 May 2023 12:11:50 +0000 (13:11 +0100)]
media: atomisp: move up sanity checks
The sanity checks were done too late, so move them up.
This fixes this smatch warning:
drivers/staging/media/atomisp/pci/sh_css_firmware.c:247 sh_css_load_firmware() warn: variable dereferenced before check 'fw_data' (see line 237)
Link: https://lore.kernel.org/r/20230524121150.435736-9-hverkuil-cisco@xs4all.nl
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans Verkuil [Wed, 24 May 2023 12:11:43 +0000 (13:11 +0100)]
media: atomisp: initialize settings to 0
Fix a compiler warning:
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c:1525:13: warning: 'settings' may be used uninitialized [-Wmaybe-uninitialized]
The 'settings' variable is actually always initialized, but the
compiler isn't quite able to figure that out. Just initialize it
to 0 to avoid this warning.
Link: https://lore.kernel.org/r/20230524121150.435736-2-hverkuil-cisco@xs4all.nl
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Uwe Kleine-König [Wed, 24 May 2023 15:16:43 +0000 (16:16 +0100)]
media: atomisp: Switch i2c drivers back to use .probe()
After commit
b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
commit
03c835f498b5 ("i2c: Switch .probe() to not take an id parameter")
convert back to (the new) .probe() to be able to eventually drop
.probe_new() from struct i2c_driver.
Link: https://lore.kernel.org/r/20230524151646.486847-3-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Tue, 16 May 2023 20:29:18 +0000 (21:29 +0100)]
media: atomisp: Allow camera_mipi_info to be NULL
camera_mipi_info is an atomisp / atomisp_gmin_platform specific struct,
allow mipi_info pointers to be NULL.
This is a preparation patch for making atomisp work with
standard v4l2 sensor drivers.
Link: https://lore.kernel.org/r/20230518153733.195306-9-hdegoede@redhat.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>
Hans de Goede [Mon, 15 May 2023 13:40:11 +0000 (14:40 +0100)]
media: atomisp: Move pad linking to atomisp_register_device_nodes()
atomisp_register_device_nodes() already iterates over the ports/sensors
in a loop and that loop already does not include the TPG input.
So we can simply setup the CSI2-port <-> ISP and sensor <-> CSI2-port
mediactl-pad links there instead of repeating the loop in
atomisp_create_pads_links(), which atomisp_register_device_nodes()
used to call later on.
Link: https://lore.kernel.org/r/20230518153733.195306-8-hdegoede@redhat.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>
Hans de Goede [Sun, 14 May 2023 20:08:29 +0000 (21:08 +0100)]
media: atomisp: Delay mapping sensors to inputs till atomisp_register_device_nodes()
Delay mapping sensors to inputs till atomisp_register_device_nodes()
time. There are 2 reasons for this:
1. This guarantees a stable input order independent of the sensor
probe order.
2. This is a preparation patch for v4l2-async sensor probing support.
Link: https://lore.kernel.org/r/20230518153733.195306-7-hdegoede@redhat.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>
Hans de Goede [Sun, 14 May 2023 19:37:00 +0000 (20:37 +0100)]
media: atomisp: Store number of sensor lanes per port in struct atomisp_device
Store number of sensor lanes per port in struct atomisp_device.
This is a preparation patch for adding v4l2-async sensor probing support.
With async probing the inputs will get registered later, but we can
already fill the sensor_lanes array when parsing the fwnodes.
Link: https://lore.kernel.org/r/20230518153733.195306-6-hdegoede@redhat.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>
Hans de Goede [Tue, 16 May 2023 20:36:14 +0000 (21:36 +0100)]
media: atomisp: Rename __get_mipi_port() to atomisp_port_to_mipi_port()
Rename __get_mipi_port() to atomisp_port_to_mipi_port(), this is not a
private (not static) function so its name should be properly prefixed.
While at is also cleanup the weird handling of ATOMISP_CAMERA_PORT_TERTIARY
this seems to be a left over from when the driver also supported CSI
receivers with only 2 ports, but those are not supported by the current
code base, so this can be cleaned up now.
Link: https://lore.kernel.org/r/20230518153733.195306-5-hdegoede@redhat.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>
Hans de Goede [Mon, 15 May 2023 18:08:05 +0000 (19:08 +0100)]
media: atomisp: Remove atomisp_video_init() parametrization
Now that we only have a single /dev/video# node it is no longer
necessary for atomisp_video_init() to be parametrized.
Remove its parameters and while at it also change the name
from the single /dev/video# node from "ATOMISP ISP PREVIEW output"
to "ATOMISP video output".
Link: https://lore.kernel.org/r/20230518153733.195306-4-hdegoede@redhat.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>
Hans de Goede [Sun, 14 May 2023 18:59:13 +0000 (19:59 +0100)]
media: atomisp: Remove unused fields from struct atomisp_input_subdev
Remove unused fields from struct atomisp_input_subdev:
1. frame_size is never used at all
2. sensor_index is always 0, just directly pass 0 in the single user.
Link: https://lore.kernel.org/r/20230518153733.195306-3-hdegoede@redhat.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>
Hans de Goede [Sun, 14 May 2023 18:51:28 +0000 (19:51 +0100)]
media: atomisp: Drop MRFLD_PORT_NUM define
The info in the MRFLD_PORT_NUM define is duplicate with
the ATOMISP_CAMERA_NR_PORTS and N_MIPI_PORT_ID enum values.
Drop the MRFLD_PORT_NUM define and switch to N_MIPI_PORT_ID
since the [sensor_]lanes arrays are in enum mipi_port_id order.
Link: https://lore.kernel.org/r/20230518153733.195306-2-hdegoede@redhat.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>
Hans de Goede [Thu, 18 May 2023 14:33:34 +0000 (15:33 +0100)]
media: atomisp: gc0310: Remove gc0310.h
Remove the gc0310.h header file, moving most of its content
into atomisp-gc0310.c and dropping some unused parts.
This brings the gc0310 sensor driver inline with other sensor
regular / non atomisp sensor drivers which usually only are
one single .c file.
Link: https://lore.kernel.org/r/20230518153214.194976-9-hdegoede@redhat.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>
Hans de Goede [Thu, 18 May 2023 14:19:14 +0000 (15:19 +0100)]
media: atomisp: gc0310: Remove gc0310_s_config() function
gc0310_s_config() used to call camera_sensor_platform_data.csi_cfg() back
when the gc0310 driver was still using the atomisp_gmin_platform code
for power-management.
Now it is just a weirdly named wrapper around gc0310_detect(), drop
gc0310_s_config() and make probe() call gc0310_detect() directly.
Link: https://lore.kernel.org/r/20230518153214.194976-8-hdegoede@redhat.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>
Hans de Goede [Thu, 18 May 2023 12:48:34 +0000 (13:48 +0100)]
media: atomisp: gc0310: Cleanup includes
Remove a bunch of unused includes and sort the remainging
includes alphabetically.
Link: https://lore.kernel.org/r/20230518153214.194976-7-hdegoede@redhat.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>
Hans de Goede [Thu, 18 May 2023 14:15:07 +0000 (15:15 +0100)]
media: atomisp: gc0310: Fix double free in gc0310_remove()
gc0310_remove() must not call kfree(dev) since the gc0310_device struct
is devm managed so explicitly freeing it causes a double free.
While at it add a missing mutex_destroy() call for the input_lock.
Link: https://lore.kernel.org/r/20230518153214.194976-6-hdegoede@redhat.com
Fixes:
340b4dd6c183 ("media: atomisp: gc0310: Use devm_kzalloc() for data struct")
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>
Hans de Goede [Thu, 18 May 2023 12:43:45 +0000 (13:43 +0100)]
media: atomisp: gc0310: Drop XXGC0310 ACPI hardware-id
The XXGC0310 ACPI hardware-id does not appear to be used in
the DSDTs of any hardware out there, so drop it.
Link: https://lore.kernel.org/r/20230518153214.194976-5-hdegoede@redhat.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>
Hans de Goede [Tue, 9 May 2023 20:10:34 +0000 (21:10 +0100)]
media: atomisp: Set asd.subdev.devnode once from isp_subdev_init_entities()
Now that we have only one /dev/video# node we can set asd.subdev.devnode
once from isp_subdev_init_entities(), replacing the hack to set it the
last opened/closed /dev/video# node from atomisp_open() /
atomisp_release().
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>
Hans de Goede [Fri, 12 May 2023 17:31:21 +0000 (18:31 +0100)]
media: atomisp: Remove in_reset argument from atomisp_css_start()
The in_reset argument to atomisp_css_start() is only ever true
in atomisp_assert_recovery_work(), drop the argument and move
the special reset handlig to atomisp_assert_recovery_work().
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>
Hans de Goede [Fri, 12 May 2023 16:27:10 +0000 (17:27 +0100)]
media: atomisp: Remove unused atomisp_get_css_pipe_id() function
Remove no longer user atomisp_get_css_pipe_id() function.
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>
Hans de Goede [Fri, 12 May 2023 16:26:11 +0000 (17:26 +0100)]
media: atomisp: Remove unused css_pipe_id argument from atomisp_css_[start|stop]()
The css_pipe_id argument pass to atomisp_css_[start|stop]() is
not used, drop it.
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>
Hans de Goede [Fri, 12 May 2023 15:27:46 +0000 (16:27 +0100)]
media: atomisp: Remove atomisp_[sub]dev_users()
The atomisp_[sub]dev_users() functions are not used anymore,
remove them.
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>
Hans de Goede [Fri, 12 May 2023 15:24:32 +0000 (16:24 +0100)]
media: atomisp: Allow system suspend to continue with open /dev/video# nodes
Just having a /dev/video# node open is not a reason to block system
suspend. At least when userspace is not streaming.
In that case the worst case scenario is that streams have been created,
but we can just destroy those before powering off the ISP and
recreate the streams on resume.
Fixing suspend when streaming is left as a FIXME item for later.
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>
Hans de Goede [Fri, 12 May 2023 15:17:54 +0000 (16:17 +0100)]
media: atomisp: Rename atomisp_destroy_pipes_stream_force() to atomisp_destroy_pipes_stream()
There now no longer is a non force version of
atomisp_destroy_pipes_stream_force() so having the _force postfix
no longer makes sense rename it to atomisp_destroy_pipes_stream().
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>
Hans de Goede [Thu, 11 May 2023 18:53:16 +0000 (19:53 +0100)]
media: atomisp: Simplify atomisp_isr() and recovery_work()
Both atomisp_isr() and recovery_work() now have a combination of:
1. "if (!isp->asd.streaming) goto out;" code at the top
2. "if (sp->asd.streaming) {}" blocks in the body which are jumped over
by the goto out.
This means that the "if (sp->asd.streaming) {}" blocks are always
executed if they are not jumped over by the goto.
Remove the unnecessary "if (sp->asd.streaming)" checks and
re-indent the code.
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>
Hans de Goede [Thu, 11 May 2023 18:35:43 +0000 (19:35 +0100)]
media: atomisp: Remove atomisp_streaming_count()
atomisp_streaming_count() is just an alias for isp->asd.streaming now,
replace it with directly checking that and remove the helper.
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>
Hans de Goede [Thu, 11 May 2023 15:14:21 +0000 (16:14 +0100)]
media: atomisp: Remove no longer used atomisp_css_flush()
Remove the no longer used atomisp_css_flush() function and merge
atomisp_assert_recovery_work() and __atomisp_css_recover() into
a single function.
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>
Hans de Goede [Thu, 11 May 2023 17:33:06 +0000 (18:33 +0100)]
media: atomisp: Turn asd->streaming state tracker into a bool
The ATOMISP_DEVICE_STREAMING_STOPPING pipe state comes from when we still
had continuous mode. This would be set when streaming from both capture +
preview devnodes when 1 of the 2 streams has been stopped and the driver
was waiting for the other stream to get stopped too.
With continuous mode gone the stopping state is no longer necessary and
asd->streaming can be changed to a bool.
Note that atomisp_assert_recovery_work() would still temporarily
set streaming to stopping, but it does so with the isp->mutex held and
changes streaming to either enabled or disabled before releasing
the mutex, so none of the consumers which care about the difference
ever see the stopping state.
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>
Hans de Goede [Thu, 11 May 2023 17:18:24 +0000 (18:18 +0100)]
media: atomisp: Simplify atomisp_pipe_check()
All switch (pipe->asd->streaming) cases in atomisp_pipe_check()
are either no-ops or never happen:
1. ATOMISP_DEVICE_STREAMING_DISABLED already is a no-op
2. The videobuf2 core guarantees that when we are streaming
vb2_is_busy() returns true. So the ATOMISP_DEVICE_STREAMING_ENABLED case
is already handled by the if above the switch (pipe->asd->streaming).
3. After recent changes pipe->asd->streaming is only ever set to
ATOMISP_DEVICE_STREAMING_STOPPING in atomisp_assert_recovery_work() and
that function holds isp->mutex and always transitions the streaming state
to ATOMISP_DEVICE_STREAMING_DISABLED or ATOMISP_DEVICE_STREAMING_ENABLED
before releasing the mutex. So atomisp_pipe_check() never sees
ATOMISP_DEVICE_STREAMING_STOPPING.
Remove the entire switch-case.
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>
Hans de Goede [Thu, 11 May 2023 15:39:37 +0000 (16:39 +0100)]
media: atomisp: Simplify atomisp_open() and atomisp_release()
Now that continuous mode is gone and we only have 1 /dev/video# node,
combined with only allowing 1 open of that /dev/video# node for now,
there is no need to check for other (sub)dev / pipe users.
Remove the unnecessary checks for a nice cleanup.
Note we also don't need to set asd->streaming to disabled since
the vb2_fop_release() call done by atomisp_release() will have called
atomisp_stop_streaming() already at this point (if necessary) and
that will have already done this.
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>
Hans de Goede [Thu, 11 May 2023 18:27:24 +0000 (19:27 +0100)]
media: atomisp: Simplify atomisp_css_[start|stop]()
Now that continuous mode is gone and we only have 1 /dev/video# node,
the videobuf2 core guarantees that atomisp_css_[start|stop]() will
only be called one at a time.
So there is no need for atomisp_streaming_count() counts.
When reqbufs has been done then the streams are guaranteed to be created,
and streaming cannot be started without reqbufs so there is no need for
atomisp_css_start() to check if it needs to create the streams.
Use this to clean-up atomisp_css_[start|stop]().
While at it also fix atomisp_css_start() not re-creating the streams
on an error, breaking the guarantee that the streams are always there
after a succesfull reqbufs call.
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>
Hans de Goede [Thu, 11 May 2023 15:03:38 +0000 (16:03 +0100)]
media: atomisp: Simplify atomisp_[start|stop]_streaming()
Now that continuous mode is gone and we only have 1 /dev/video# node,
the videobuf2 core guarantees that atomisp_[start|stop]_streaming() will
only be called one at a time.
So there is no need to check for things like the isp is already streaming
when starting, or other streams still being active while stopping.
Remove checks for these from atomisp_[start|stop]_streaming().
While at it also improve the logging a bit:
1. Remove the dev_err(isp->dev, "atomisp_reset") logged on every
stream stop (even though everything is fine.
2. Log a message when starting/stopping the sensor stream fails
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>
Hans de Goede [Tue, 9 May 2023 21:12:16 +0000 (22:12 +0100)]
media: atomisp: Remove atomisp_sensor_start_stream()
Now that we no longer have continuous mode we always want to
start the sensor on the first atomisp_start_streaming() call
and stop it on the first atomisp_stop_streaming() call.
Remove atomisp_sensor_start_stream() which returned the number
of streams which should be active before starting the sensor
and always start/stop the sensor directly.
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>
Hans de Goede [Thu, 11 May 2023 14:51:21 +0000 (15:51 +0100)]
media: atomisp: Remove isp_timeout flag
isp_timeout only ever gets set in __atomisp_css_recover() and then
immediately gets cleared again after calling atomisp_reset().
All this happens with isp->mutex held.
The only consumer of isp->isp_timeout is atomisp_stop_streaming(), which
also holds isp->mutex and which is *not* called by atomisp_reset().
Since both hold isp->mutex and since __atomisp_css_recover() clears
isp_timeout before releasing the mutex, atomisp_stop_streaming() can
never see isp_timeout being true, so just remove the flag.
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>
Hans de Goede [Wed, 10 May 2023 20:21:51 +0000 (21:21 +0100)]
media: atomisp: Remove unused mipi_frame_size field from atomisp_[sub_]device
Both the atomisp_device and the atomisp_sub_device structs have
an unused mipi_frame_size field, remove the field from both.
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>
Hans de Goede [Sun, 7 May 2023 20:21:30 +0000 (21:21 +0100)]
media: atomisp: Remove a bunch of unused atomisp_css_*() functions
Remove various unused atomisp_css_*() functions from
atomisp_compat_css20.c.
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>
Hans de Goede [Sun, 7 May 2023 20:19:33 +0000 (21:19 +0100)]
media: atomisp: Remove atomisp_subdev_register_video_nodes() helper
Now that there is only 1 /dev/video# node left there is no need to
do this in a helper. Just make atomisp_register_device_nodes()
call video_register_device() directly.
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>
Hans de Goede [Sun, 7 May 2023 20:14:47 +0000 (21:14 +0100)]
media: atomisp: Remove 1 line atomisp_flush_bufs_and_wakeup() helper
After recent changes this now is just a wrapper around
atomisp_flush_video_pipe(). Make its single caller call
atomisp_flush_video_pipe() directly and drop the helper.
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>
Hans de Goede [Sun, 7 May 2023 20:11:42 +0000 (21:11 +0100)]
media: atomisp: Remove source_pad parameter from functions and structs
Now that there is only 1 source-pad for an asd there is no need
to have a parameter for this in various places.
Remove the source_pad function parameter and
atomisp_sub_device.capture_pad data member.
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>
Hans de Goede [Sun, 7 May 2023 19:42:26 +0000 (20:42 +0100)]
media: atomisp: Rename video_out_preview to video_out
Now that we have only 1 /dev/video# node for output for all different
run-modes (with only 1 run-mode at a time) using video_out_preview for
the remaining atomisp_pipe does not properly reflect that this is
*the* output pipe. Fo the following renames to fix the naming:
s/video_out_preview/video_out/
s/ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW/ATOMISP_SUBDEV_PAD_SOURCE/
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>
Hans de Goede [Sun, 7 May 2023 14:20:22 +0000 (15:20 +0100)]
media: atomisp: Drop atomisp_is_vf_pipe()
Since there only is one /dev/video# node now (no more continuous mode),
there are now no longer separate main capture + view-finder pipes.
We are now always on the main pipe, so atomisp_is_vf_pipe() should
always return false now. Drop any checks using it, replacing them
with the code-path for a false return.
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>
Hans de Goede [Sun, 7 May 2023 11:54:26 +0000 (12:54 +0100)]
media: atomisp: Register only 1 /dev/video# node
Now that we no longer support continuous mode and thus no longer support
streaming from 2 /dev/video# nodes at the same time, there is no need
to have a separate /dev/video# node (+ matching v4l2-subdev pads)
for each run-mode.
Keep the video_out_preview /dev/video0 device and remove
the video_out_video_capture / video_out_vf / video_out_capture
video-devices (atomisp_pipe-s) and also remove the matching
ATOMISP_SUBDEV_PAD_SOURCE_VIDEO / ATOMISP_SUBDEV_PAD_SOURCE_VF /
ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE source-pads.
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>
Hans de Goede [Sun, 7 May 2023 18:11:48 +0000 (19:11 +0100)]
media: atomisp: Replace source-pad checks with run-mode checks
Currently atomisp behavior is determined by a mix of which /dev/video# node
(which isp-subdev source-pad) is opened + which run-mode is set.
With various combinations not being allowed and likely leading to crashes
due to lack of error checking.
Now that we no longer support continuous mode and thus no longer support
streaming from 2 /dev/video# nodes at the same time, there is no need
to have a separate /dev/video# node for each run-mode. Instead the plan is
to support the 3 different run-modes on a single /dev/video# node.
Since we are moving to a single isp-subdev source-pad, the behavior should
then be solely and consistently be defined by the run-mode.
Replace various source-pad checks with run-mode checks in preparation for
moving to a single source-pad. In some places the new run-mode checks
overlap with existing run-mode checks and the checks are folded together
into a single check.
This removes handling of the ATOMISP_SUBDEV_PAD_SOURCE_VF source-pad,
this source-pad was only useful for continuous mode, for which support has
been removed.
Note that currently the only run-mode which we actually have been able to
get to work is the video-capture with scaler aka preview mode and as such
that is also the only run-mode tested. This patch is intended to preserve
the current (known to not work 100%) behavior of the other run-modes, so
that those maybe can be enabled later.
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>
Hans de Goede [Sun, 7 May 2023 17:38:10 +0000 (18:38 +0100)]
media: atomisp: Drop atomisp_get_css_buf_type()
Since continuous mode has been removed, there no longer is the option for
separate capture output + viewfinder output streams at the same time.
So all buffers queued by userspace are now for the normal output stream,
remove atomisp_get_css_buf_type() and always use
IA_CSS_BUFFER_TYPE_OUTPUT_FRAME for buffers queued by userspace.
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>
Hans de Goede [Sun, 7 May 2023 15:23:48 +0000 (16:23 +0100)]
media: atomisp: Remove isp->need_gfx_throttle field
Remove the isp->need_gfx_throttle field it is only ever set and
never read.
Also the code setting it is broken, comparing run_mode->val to
ATOMISP_SUBDEV_PAD_SOURCE_VIDEO which are not of the same type /
not part of the same enum.
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>
Hans de Goede [Sun, 7 May 2023 15:16:06 +0000 (16:16 +0100)]
media: atomisp: Remove Continuous capture and SDV run-modes
Since we no longer support Continuous mode, setting the run_mode to
ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE no longer make sense, so remove
this.
While at it, also remove ATOMISP_RUN_MODE_SDV, which was never exposed
to userspace in the first place.
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>
Hans de Goede [Sat, 6 May 2023 18:56:05 +0000 (19:56 +0100)]
media: atomisp: Remove res_overflow parameter from atomisp_try_fmt()
The only remaining caller of atomisp_try_fmt() always passes NULL
for the res_overflow parameter. Drop it and simplify atomisp_try_fmt().
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>
Kate Hsuan [Mon, 8 May 2023 06:26:32 +0000 (07:26 +0100)]
media: atomisp: sh_css_mipi: Remove #ifdef ISP2401
The actions of ISP2401 and 2400 are determined at the runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-5-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Kate Hsuan [Mon, 8 May 2023 06:26:31 +0000 (07:26 +0100)]
media: atomisp: sh_css_firmware: determine firmware version at runtime
The firmware version of ISP2401 and 2400 is determined at runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-4-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Kate Hsuan [Mon, 8 May 2023 06:26:30 +0000 (07:26 +0100)]
media: atomisp: sh_css_sp: Remove #ifdef ISP2401
The actions of ISP2401 and 2400 will be determined at the runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-3-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Kate Hsuan [Mon, 8 May 2023 06:26:29 +0000 (07:26 +0100)]
media: atomisp: runtime: frame: remove #ifdef ISP2401
The actions of ISP2401 and 2400 are determined at the runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-2-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Kate Hsuan [Mon, 8 May 2023 06:26:28 +0000 (07:26 +0100)]
media: atomisp: sh_css: Remove #ifdef ISP2401
The actions of ISP2401 and 2400 are determined at the runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-1-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Thu, 20 Apr 2023 03:47:57 +0000 (06:47 +0300)]
media: uvcvideo: Constify descriptor buffers
There is no need to modify the content of UVC descriptor buffers during
parsing. Make all the corresponding pointers const to avoid unintended
modifications.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Thu, 20 Apr 2023 03:47:57 +0000 (06:47 +0300)]
media: uvcvideo: Constify formats, frames and intervals
The formats, frames and intervals stored in the uvc_streaming structure
are not meant to change after being parsed at probe time. Make them
const to prevent unintended modifications, and adapt the probe code
accordingly to use non-const pointers during parsing.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Fri, 5 May 2023 11:45:24 +0000 (14:45 +0300)]
media: uvcvideo: Increment intervals pointer at end of parsing
The intervals pointer is incremented for each interval when parsing the
format descriptor. This doesn't cause any issue as such, but gets in the
way of constifying some pointers. Modify the parsing code to index the
intervals pointer as an array and increment it in one go at end of
parsing.
Careful readers will notice that the maxIntervalIndex variable is set to
1 instead of n - 2 when bFrameIntervalType has a zero value. This is
functionally equivalent, as n is equal to 3 in that case.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Fri, 5 May 2023 11:45:24 +0000 (14:45 +0300)]
media: uvcvideo: Reorganize format descriptor parsing
Format descriptor parsing has grown over time and now mixes parsing of
frame intervals with various quirk handling. Reorganize it to make the
code easier to follow, by parsing frame intervals first, and then
applying fixes and quirks. No functional change is intended.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Fri, 5 May 2023 11:45:24 +0000 (14:45 +0300)]
media: uvcvideo: Use clamp() to replace manual implementation
The kernel has a nice clamp() macro, use it to replace a manual
implementation based on min() and max(). No functional change is
intended.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Thu, 20 Apr 2023 03:33:03 +0000 (06:33 +0300)]
media: uvcvideo: Rename uvc_format 'frame' field to 'frames'
The uvc_format 'frame' field points to an array of frames. Rename it to
'frames' to make this clearer.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Thu, 20 Apr 2023 03:33:03 +0000 (06:33 +0300)]
media: uvcvideo: Rename uvc_streaming 'format' field to 'formats'
The uvc_streaming 'format' field points to an array of formats. Rename
it to 'formats' to make this clearer.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dmitry Perchanov [Thu, 20 Apr 2023 09:06:55 +0000 (12:06 +0300)]
media: uvcvideo: Enable Intel RealSense metadata for devices
Intel RealSense UVC Depth cameras produce metadata in a
vendor-specific format that is already supported by the uvcvideo driver.
Enable handling of this metadata for 7 additional RealSense devices.
Co-developed-by: Yu MENG <yu1.meng@intel.com>
Co-developed-by: Evgeni Raikhel <evgeni.raikhel@intel.com>
Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dmitry Perchanov [Thu, 1 Jun 2023 16:08:46 +0000 (19:08 +0300)]
media: uapi: v4l: Intel metadata format update
Update metadata structure for Intel RealSense UVC/MIPI cameras.
Compliant to Intel Configuration version 3.
Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>