1186629 Commits

Author SHA1 Message Date
Hans de Goede
96f18f25c1 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>
2023-06-09 15:07:08 +01:00
Hans de Goede
5b9ca47a25 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>
2023-06-09 15:06:05 +01:00
Hans de Goede
64be20708a 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>
2023-06-09 15:04:39 +01:00
Hans de Goede
45b4ab382a 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>
2023-06-09 15:02:57 +01:00
Hans de Goede
9af6100f4f 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>
2023-06-09 15:01:08 +01:00
Hans de Goede
1ad997e831 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>
2023-06-09 14:59:58 +01:00
Hans de Goede
1bb2a551e6 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>
2023-06-09 14:59:28 +01:00
Hans de Goede
f5e381ffb6 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>
2023-06-09 14:59:16 +01:00
Hans de Goede
63558464ad 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>
2023-06-09 14:58:11 +01:00
Hans de Goede
2746a966f9 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>
2023-06-09 14:57:12 +01:00
Hans de Goede
76d2d7d6af 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>
2023-06-09 14:55:56 +01:00
Hans de Goede
250781c5a2 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>
2023-06-09 14:54:54 +01:00
Hans de Goede
ae39964d2c 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>
2023-06-09 14:53:23 +01:00
Hans de Goede
1180d072e0 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>
2023-06-09 14:51:47 +01:00
Hans de Goede
e5fab487ea 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>
2023-06-09 14:51:28 +01:00
Hans de Goede
5ab97df864 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>
2023-06-09 14:50:40 +01:00
Hans de Goede
4d141d3fae 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>
2023-06-09 14:50:06 +01:00
Hans de Goede
2cb61011bf 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>
2023-06-09 14:48:23 +01:00
Hans de Goede
bcc90bb31c 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>
2023-06-09 14:47:04 +01:00
Hans de Goede
3fb3cd02d2 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>
2023-06-09 14:46:52 +01:00
Hans de Goede
b19f8ef5bd 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>
2023-06-09 14:45:04 +01:00
Hans de Goede
0f072c1e24 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>
2023-06-09 14:43:16 +01:00
Hans de Goede
e1278e6187 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>
2023-06-09 14:41:22 +01:00
Hans de Goede
347f2e56b9 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>
2023-06-09 14:39:33 +01:00
Hans de Goede
71a85e054f 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>
2023-06-09 14:37:51 +01:00
Hans de Goede
3f3ee94c89 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>
2023-06-09 14:37:12 +01:00
Hans de Goede
1ae393ea3d 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>
2023-06-09 14:36:09 +01:00
Hans de Goede
820a1338d6 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>
2023-06-09 14:35:03 +01:00
Hans de Goede
fb86cf8bd8 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>
2023-06-09 14:34:01 +01:00
Hans de Goede
6f48bc9e49 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>
2023-06-09 14:33:44 +01:00
Hans de Goede
28714506c3 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>
2023-06-09 14:33:40 +01:00
Hans de Goede
8fd3c9a468 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>
2023-06-09 14:32:28 +01:00
Hans de Goede
e4454e06e5 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>
2023-06-09 14:32:16 +01:00
Hans de Goede
aca8a1dfb9 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>
2023-06-09 14:31:40 +01:00
Hans de Goede
26dcabc0dd 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>
2023-06-09 14:30:39 +01:00
Hans de Goede
d957824bf8 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>
2023-06-09 14:30:01 +01:00
Hans de Goede
ea3600379e 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>
2023-06-09 14:29:57 +01:00
Hans de Goede
006f27897c 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>
2023-06-09 14:29:21 +01:00
Hans de Goede
1b9a80a47d 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>
2023-06-09 14:28:22 +01:00
Hans de Goede
7943916bd4 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>
2023-06-09 14:27:06 +01:00
Hans de Goede
649920afc4 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>
2023-06-09 14:26:04 +01:00
Kate Hsuan
5c3213e9e2 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>
2023-06-09 14:24:35 +01:00
Kate Hsuan
08b9c82087 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>
2023-06-09 14:23:14 +01:00
Kate Hsuan
72c1c48553 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>
2023-06-09 14:22:58 +01:00
Kate Hsuan
5925dc0f30 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>
2023-06-09 14:22:42 +01:00
Kate Hsuan
bc13f2ffd5 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>
2023-06-09 14:22:26 +01:00
Laurent Pinchart
102df33eba 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>
2023-06-09 14:11:57 +01:00
Laurent Pinchart
af621ba2ed 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>
2023-06-09 14:11:55 +01:00
Laurent Pinchart
7691d900b9 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>
2023-06-09 14:11:54 +01:00
Laurent Pinchart
c9d597b9b7 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>
2023-06-09 14:11:52 +01:00