platform/kernel/linux-starfive.git
22 months agomedia: atomisp: Fix VIDIOC_TRY_FMT
Hans de Goede [Sat, 13 Aug 2022 14:53:00 +0000 (16:53 +0200)]
media: atomisp: Fix VIDIOC_TRY_FMT

atomisp_try_fmt() calls the sensor's try_fmt handler but it does
not copy the result back to the passed in v4l2_pix_format under
some circumstances.

Potentially returning an unsupported resolution to userspace,
which VIDIOC_TRY_FMT is not supposed to do.

atomisp_set_fmt() also uses atomisp_try_fmt() and relies
on this wrong behavior. The VIDIOC_TRY_FMT call passes NULL for
the res_overflow argument where as the atomisp_set_fmt() call
passes non NULL.

Use the res_overflow argument to differentiate between the 2 callers
and always propagate the sensors result in the VIDIOC_TRY_FMT case.

This fixes the resolution list in camorama showing resolutions like e.g.
1584x1184 instead of 1600x1200.

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>
22 months agomedia: atomisp-notes: Add info about sensors v4l2_get_subdev_hostdata() use
Hans de Goede [Sat, 13 Aug 2022 09:01:13 +0000 (11:01 +0200)]
media: atomisp-notes: Add info about sensors v4l2_get_subdev_hostdata() use

Add info about sensors v4l2_get_subdev_hostdata() use, to notes.txt.

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>
22 months agomedia: atomisp-ov2680: Improve ov2680_set_fmt() error handling
Hans de Goede [Sat, 13 Aug 2022 09:03:23 +0000 (11:03 +0200)]
media: atomisp-ov2680: Improve ov2680_set_fmt() error handling

Exit with an error on any i2c-write errors, rather then only
exiting with an error when ov2680_get_intg_factor() 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>
22 months agomedia: atomisp-ov2680: Don't take the input_lock for try_fmt calls.
Hans de Goede [Sat, 13 Aug 2022 08:30:34 +0000 (10:30 +0200)]
media: atomisp-ov2680: Don't take the input_lock for try_fmt calls.

On ov2680_set_fmt() calls with format->which == V4L2_SUBDEV_FORMAT_TRY,
ov2680_set_fmt() does not talk to the sensor, so there is no need to
lock the dev->input_lock mutex in this case.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: atomisp-ov2680: Fix ov2680_set_fmt()
Hans de Goede [Sat, 13 Aug 2022 08:12:39 +0000 (10:12 +0200)]
media: atomisp-ov2680: Fix ov2680_set_fmt()

On sets actually store the set (closest) format inside ov2680_device.dev,
so that it also properly gets returned by get_fmt.

This fixes the following problem:

1. App does an VIDIOC_SET_FMT 640x480, calling ov2680_set_fmt()
2. Internal buffers (atomisp_create_pipes_stream()) get allocated
   at 640x480 size by atomisp_set_fmt()
3. ov2680_get_fmt() gets called later on and returns 1600x1200
   since ov2680_device.dev was not updated. So things get configured
   to stream at 1600x1200, but the internal buffers created during
   atomisp_create_pipes_stream() do not get updated in size
4. streaming starts, internal buffers overflow and the entire
   machine freezes eventually due to memory being corrupted

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>
22 months agomedia: atomisp_gmin_platform: Switch to use acpi_evaluate_dsm_typed()
Andy Shevchenko [Sat, 30 Jul 2022 15:59:04 +0000 (17:59 +0200)]
media: atomisp_gmin_platform: Switch to use acpi_evaluate_dsm_typed()

The acpi_evaluate_dsm_typed() provides a way to check the type of the
object evaluated by _DSM call. Use it instead of open coded variant.

Link: https://lore.kernel.org/r/20220730155905.90091-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: dt-bindings: media: samsung,exynos5250-gsc: convert to dtschema
Krzysztof Kozlowski [Sun, 26 Jun 2022 16:33:00 +0000 (18:33 +0200)]
media: dt-bindings: media: samsung,exynos5250-gsc: convert to dtschema

Convert the Samsung Exynos SoC G-Scaler bindings to DT schema.

Changes done during conversion:
1. A typical (already used) properties like clocks, iommus and
   power-domains.
2. Require clocks, because they are essential for the block to operate.
3. Describe the differences in clocks between the Exynos5250/5420 and
   the Exynos5433 G-Scalers.  This includes the fifth Exynos5433 clock
   "gsd" (GSCL Smart Deck) which was added to the DTS, but not to the
   bindings and Linux driver.  Similarly to Exynos5433 DECON change [1],
   the clock should be used.

[1] https://lore.kernel.org/all/6270db2d-667d-8d6f-9289-be92da486c25@samsung.com/

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: dt-bindings: dongwoon,dw9714: convert to dtschema
Krzysztof Kozlowski [Thu, 1 Sep 2022 07:14:37 +0000 (09:14 +0200)]
media: dt-bindings: dongwoon,dw9714: convert to dtschema

Convert Dongwoon Anatech DW9714 camera voice coil lens driver to DT
schema and extend the bindings with vcc-supply (already used by driver)
and powerdown-gpios (based on datasheet, not used by the driver).

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mc: convert pipeline funcs to take media_pad
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:39 +0000 (16:13 +0200)]
media: mc: convert pipeline funcs to take media_pad

Now that the pipeline is stored into pads instead of entities, we can
change the relevant functions to take pads instead of entities.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mc: entity: Add has_pad_interdep entity operation
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:38 +0000 (16:13 +0200)]
media: mc: entity: Add has_pad_interdep entity operation

Add a new media entity operation, has_pad_interdep. The optional op is
used to discover the pad interdependencies inside an entity during the
pipeline construction.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mc: entity: Rewrite media_pipeline_start()
Laurent Pinchart [Wed, 31 Aug 2022 14:13:37 +0000 (16:13 +0200)]
media: mc: entity: Rewrite media_pipeline_start()

[Note: the code is mostly from Laurent but the patch description is from Tomi]

The media_pipeline_start() and media_pipeline_stop() functions use the
media graph walk API to traverse the graph and validate the pipeline.
The graph walk traverses the media graph following links between the
entities.

Also, while the pipeline can't change between the start and stop calls,
the graph is walked again from scratch at stop time, or any time a
driver needs to inspect the pipeline.

With the upcoming multiplexed streams support we will need a bit more
intelligent pipeline construction, as e.g. two independent streams may
be passing through a single entity via separate pads in which case
those pads should not be part of the same pipeline.

This patch essentially rewrites the media_pipeline_start/stop so that
a pipeline is defined as a set of pads instead of entities and the media
graph traversal considers the pad interdependencies when choosing which
links to follow.

Currently all the entity's pads are considered as interdependent. This
means that the behavior with all the current drivers stays the same, but
in the future we can define a more fine-grained pipeline construction.

Additionally the media pipeline's pads are cached at
media_pipeline_start() time, and re-used at media_pipeline_stop() which
avoid the need to re-walk the whole graph as the previous implementation
did.

Also, caching pads in the pipeline can serve in the future as the
foundation to provide a better API than the media graph walk to drivers
to iterate over pads and entities in the pipeline.

Note that the old media_pipeline_start/stop used the media graph walk
API. The new version does not use the media graph walk API, but instead
a new implementation.

There are two reasons for not changing the graph walk: it proved to be
rather difficult to change the graph walk to have the features
implemented in this patch, and second, this keeps the backward
compatibility of the graph walk as there are users of the graph walk API

The long term plan is that all the existing code would be converted to
use the new cached pipeline, thus allowing us to remove the graph walk.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: drivers: use video_device_pipeline_alloc_start()
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:36 +0000 (16:13 +0200)]
media: drivers: use video_device_pipeline_alloc_start()

Use video_device_pipeline_alloc_start() instead of manually
allocating/managing the media pipeline storage.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mc: entity: add alloc variant of pipeline_start
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:35 +0000 (16:13 +0200)]
media: mc: entity: add alloc variant of pipeline_start

Add new variant of media_pipeline_start(), media_pipeline_alloc_start().

media_pipeline_alloc_start() can be used by drivers that do not need to
extend the media_pipeline. The function will either use the pipeline
already associated with the entity, if such exists, or allocate a new
pipeline.

When media_pipeline_stop() is called and the pipeline's use count drops
to zero, the pipeline is automatically freed.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: drivers: use video_device_pipeline()
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:34 +0000 (16:13 +0200)]
media: drivers: use video_device_pipeline()

Use video_device_pipeline() in the drivers instead of
media_entity_pipeline().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: drivers: use video device pipeline start/stop
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:33 +0000 (16:13 +0200)]
media: drivers: use video device pipeline start/stop

Convert the media drivers to use video device based pipeline start/stop
where possible.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: v4l2-dev: Add videodev wrappers for media pipelines
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:32 +0000 (16:13 +0200)]
media: v4l2-dev: Add videodev wrappers for media pipelines

With the upcoming stream related improvements to the pipelines, the
pipelines are moved from media entities to media pads. As the drivers
currently use the pipelines with the entity based model, moving the
pipelines to pads will cause changes to the drivers.

However, most of the uses of media pipelines are related to a video
device (a DMA engine) with a single pad, and thus there's never a need
to support multiple pads in these use cases. We can avoid pushing the
complexities of the pad based model to the drivers by adding video
device wrappers for the pipeline related functions.

This patch adds a number of wrappers to media_pipeline functions, all of
which take a video_device as a parameter (instead of a media_entity),
and verify that there's just one pad.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mc: entity: Add media_entity_pipeline() to access the media pipeline
Laurent Pinchart [Wed, 31 Aug 2022 14:13:31 +0000 (16:13 +0200)]
media: mc: entity: Add media_entity_pipeline() to access the media pipeline

Replace direct access to the pipe field in drivers with a new helper
function. This will allow easier refactoring of media pipeline handling
in the MC core behind the scenes without affecting drivers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mc: entity: Move media_entity_get_fwnode_pad() out of graph walk section
Laurent Pinchart [Wed, 31 Aug 2022 14:13:30 +0000 (16:13 +0200)]
media: mc: entity: Move media_entity_get_fwnode_pad() out of graph walk section

The media_entity_get_fwnode_pad() function is unrelated to the graph
traversal code that it is currently bundled with. Move it with the
media_entity_remote_pad() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mc: entity: Merge media_entity_enum_init and __media_entity_enum_init
Laurent Pinchart [Wed, 31 Aug 2022 14:13:29 +0000 (16:13 +0200)]
media: mc: entity: Merge media_entity_enum_init and __media_entity_enum_init

The media_entity_enum_init() function is a wrapper around
__media_entity_enum_init() that turns a media_device pointer argument
into the maximum entity ID in the corresponding media graph.
__media_entity_enum_init() is never used outside of
media_entity_enum_init(), so the two functions can be merged together.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mc: entity: Add iterator helper for entity pads
Jacopo Mondi [Wed, 31 Aug 2022 14:13:28 +0000 (16:13 +0200)]
media: mc: entity: Add iterator helper for entity pads

Add an iterator helper to easily cycle through all pads in an entity and
use it in media-entity and media-device code where appropriate.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mc: entity: Rename streaming_count -> start_count
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:27 +0000 (16:13 +0200)]
media: mc: entity: Rename streaming_count -> start_count

'streaming_count' is a bit misleading name, as the count is increased
with media_pipeline_start(). Let's rename it to 'start_count' instead.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: subdev: increase V4L2_FRAME_DESC_ENTRY_MAX to 8
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:26 +0000 (16:13 +0200)]
media: subdev: increase V4L2_FRAME_DESC_ENTRY_MAX to 8

V4L2_FRAME_DESC_ENTRY_MAX is currently set to 4. In theory it's possible
to have an arbitrary amount of streams in a single pad, so preferably
there should be no hardcoded maximum number.

However, I believe a reasonable max is 8, which would cover a CSI-2 pad
with 4 streams of pixel data and 4 streams of metadata.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: media-entity.h: add include for min()
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:25 +0000 (16:13 +0200)]
media: media-entity.h: add include for min()

./include/media/media-entity.h:595:34: error: implicit declaration of function ‘min’

Include minmax.h to get the definition for min().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: Documentation: mc: add definitions for stream and pipeline
Tomi Valkeinen [Wed, 31 Aug 2022 14:13:24 +0000 (16:13 +0200)]
media: Documentation: mc: add definitions for stream and pipeline

The doc talks about streams and pipelines, but doesn't really define
them. This is an attempt to define them according to my understanding.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: Remove incorrect comment from struct v4l2_fwnode_endpoint
Sakari Ailus [Mon, 5 Sep 2022 12:35:34 +0000 (14:35 +0200)]
media: Remove incorrect comment from struct v4l2_fwnode_endpoint

struct v4l2_fwnode_endpoint was zeroed previously apart from the endpoint
information itself when the endpoint properties were parsed. Now this
hasn't been the case for a few years so remove the comment.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: sun6i-mipi-csi2: Depend on PHY_SUN6I_MIPI_DPHY
Sakari Ailus [Mon, 5 Sep 2022 09:52:35 +0000 (11:52 +0200)]
media: sun6i-mipi-csi2: Depend on PHY_SUN6I_MIPI_DPHY

PHY_SUN6I_MIPI_DPHY is not a freely selectable option and so may not
always be available. Depend on it instead.

Fixes: 94d7fd9692b5 ("media: sunxi: Depend on GENERIC_PHY_MIPI_DPHY")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: ov8865: Fix an error handling path in ov8865_probe()
Christophe JAILLET [Sun, 7 Aug 2022 06:43:29 +0000 (08:43 +0200)]
media: ov8865: Fix an error handling path in ov8865_probe()

The commit in Fixes also introduced some new error handling which should
goto the existing error handling path.
Otherwise some resources leak.

Fixes: 73dcffeb2ff9 ("media: i2c: Support 19.2MHz input clock in ov8865")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: ar0521: Fix return value check in writing initial registers
Sakari Ailus [Tue, 30 Aug 2022 10:32:36 +0000 (12:32 +0200)]
media: ar0521: Fix return value check in writing initial registers

The return value from register writes is ignored apart from the last
value. Fix this.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: v4l: subdev: Fail graciously when getting try data for NULL state
Sakari Ailus [Fri, 26 Aug 2022 11:53:58 +0000 (13:53 +0200)]
media: v4l: subdev: Fail graciously when getting try data for NULL state

The state argument for the functions for obtaining various parts of the
state is NULL if it is called by drivers for active state. Fail graciously
in that case instead of dereferencing a NULL pointer.

Suggested-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: ipu3-imgu: Fix NULL pointer dereference in active selection access
Sakari Ailus [Thu, 25 Aug 2022 18:36:37 +0000 (20:36 +0200)]
media: ipu3-imgu: Fix NULL pointer dereference in active selection access

What the IMGU driver did was that it first acquired the pointers to active
and try V4L2 subdev state, and only then figured out which one to use.

The problem with that approach and a later patch (see Fixes: tag) is that
as sd_state argument to v4l2_subdev_get_try_crop() et al is NULL, there is
now an attempt to dereference that.

Fix this.

Also rewrap lines a little.

Fixes: 0d346d2a6f54 ("media: v4l2-subdev: add subdev-wide state struct")
Cc: stable@vger.kernel.org # for v5.14 and later
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: ar0521: Remove redundant variable ret
Sakari Ailus [Sun, 14 Aug 2022 17:42:13 +0000 (19:42 +0200)]
media: ar0521: Remove redundant variable ret

ret in ar0521_set_fmt is never set to values other than 0. Replace it with
plain 0.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: ar0521: fix error return code in ar0521_power_on()
Yang Yingliang [Fri, 15 Jul 2022 08:59:24 +0000 (10:59 +0200)]
media: ar0521: fix error return code in ar0521_power_on()

Return error code if ar0521_write_regs() fails in ar0521_power_on().

Fixes: 852b50aeed15 ("media: On Semi AR0521 sensor driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Krzysztof Hałasa <khalasa@piap.pl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: i2c: mt9v111: Fix typo 'the the' in comment
Slark Xiao [Fri, 22 Jul 2022 01:52:11 +0000 (03:52 +0200)]
media: i2c: mt9v111: Fix typo 'the the' in comment

Replace 'the the' with 'the' in the comment.

Signed-off-by: Slark Xiao <slark_xiao@163.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: v4l2: Fix v4l2_i2c_subdev_set_name function documentation
Alexander Stein [Fri, 22 Jul 2022 07:11:31 +0000 (09:11 +0200)]
media: v4l2: Fix v4l2_i2c_subdev_set_name function documentation

The doc says the I²C device's name is used if devname is NULL, but
actually the I²C device driver's name is used.

Fixes: 0658293012af ("media: v4l: subdev: Add a function to set an I²C sub-device's name")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: ov5640: Use runtime PM
Paul Elder [Thu, 21 Jul 2022 07:41:38 +0000 (09:41 +0200)]
media: ov5640: Use runtime PM

Switch to using runtime PM for power management. Make it optional,
however, to support ACPI.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: staging: ipu3-imgu: Fix BNR wb gain documentation
Jean-Michel Hautbois [Fri, 17 Jun 2022 08:45:19 +0000 (10:45 +0200)]
media: staging: ipu3-imgu: Fix BNR wb gain documentation

The documentation states that the BNR factor is a multiplier coded as
u3.13 and with a range of (0, 8). This is not correct, as the isp is
adding 1.0 to the gain applied, ie Pout = { Pin * (1 + Gx) }.

It means that a gain of 1.0 should be coded as 0.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: hantro: Allows luma and chroma depth to be different
Benjamin Gaignard [Mon, 29 Aug 2022 16:21:59 +0000 (18:21 +0200)]
media: hantro: Allows luma and chroma depth to be different

Luma and chroma depth are set on different hardware registers.
Even if they aren't identical the bitstream can be compliant
to HEVC specifications and decoded by the hardware.

With this patch TSUNEQBD_A_MAIN10_Technicolor_2 conformance test
is successfully decoded.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: hantro: imx8m: Enable 10bit decoding
Benjamin Gaignard [Mon, 29 Aug 2022 16:21:58 +0000 (18:21 +0200)]
media: hantro: imx8m: Enable 10bit decoding

Expose 10bit pixel formats to enable 10bit decoding in IMX8M SoCs.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: Hantro: HEVC: Allows 10-bit bitstream
Benjamin Gaignard [Mon, 29 Aug 2022 16:21:57 +0000 (18:21 +0200)]
media: Hantro: HEVC: Allows 10-bit bitstream

Stop limiting HEVC support to 8-bits bitstreams also
accept 10-bits bitstreams.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: hantro: postproc: Configure output regs to support 10bit
Benjamin Gaignard [Mon, 29 Aug 2022 16:21:56 +0000 (18:21 +0200)]
media: hantro: postproc: Configure output regs to support 10bit

Move output format setting in postproc and make sure that
8/10bit configuration is correctly set.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: hantro: HEVC: Fix chroma offset computation
Benjamin Gaignard [Mon, 29 Aug 2022 16:21:55 +0000 (18:21 +0200)]
media: hantro: HEVC: Fix chroma offset computation

The chroma offset depends of the bitstream depth.
Make sure that ctx->bit_depth is used to compute it.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: hantro: HEVC: Fix auxilary buffer size calculation
Benjamin Gaignard [Mon, 29 Aug 2022 16:21:54 +0000 (18:21 +0200)]
media: hantro: HEVC: Fix auxilary buffer size calculation

SAO and FILTER buffers size depend of the bit depth.
Make sure we have enough space for 10bit bitstreams.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: hantro: Store HEVC bit depth in context
Benjamin Gaignard [Mon, 29 Aug 2022 16:21:53 +0000 (18:21 +0200)]
media: hantro: Store HEVC bit depth in context

Store HEVC bit depth in context.
Bit depth is equal to hevc sps bit_depth_luma_minus8 + 8.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: meson: vdec: fix possible refcount leak in vdec_probe()
Hangyu Hua [Tue, 6 Sep 2022 07:46:30 +0000 (09:46 +0200)]
media: meson: vdec: fix possible refcount leak in vdec_probe()

v4l2_device_unregister need to be called to put the refcount got by
v4l2_device_register when vdec_probe fails or vdec_remove is called.

Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: platform: cros-ec: Add Kuldax to the match table
Rory Liu [Tue, 6 Sep 2022 03:30:16 +0000 (05:30 +0200)]
media: platform: cros-ec: Add Kuldax to the match table

The Google Kuldax device uses the same approach as the Google Brask
which enables the HDMI CEC via the cros-ec-cec driver.

Signed-off-by: Rory Liu <hellojacky0226@hotmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: MAINTAINERS: rectify entry in SAA7146 VIDEO4LINUX-2 DRIVER
Lukas Bulwahn [Mon, 5 Sep 2022 10:29:39 +0000 (12:29 +0200)]
media: MAINTAINERS: rectify entry in SAA7146 VIDEO4LINUX-2 DRIVER

Commit e33fdb5a0249 ("media: saa7146: deprecate hexium_gemini/orion, mxb
and ttpci") moves some media drivers to the staging subsystem, and
unfortunately only partially adjusts the entry in MAINTAINERS.

Hence, ./scripts/get_maintainer.pl --self-test=patterns complains about a
broken reference.

As the files matching include/media/drv-intf/saa7146* are moved to
drivers/staging/media/deprecated/saa7146/common, this directory is already
covered by the existing file entry
drivers/staging/media/deprecated/saa7146/.

Repair this file reference in SAA7146 VIDEO4LINUX-2 DRIVER.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: MAINTAINERS: adjust entry to zoran driver movement
Lukas Bulwahn [Mon, 5 Sep 2022 10:14:16 +0000 (12:14 +0200)]
media: MAINTAINERS: adjust entry to zoran driver movement

Commit 2a0c28063de2 ("media: zoran: move to mainline") moves the zoran
driver from the staging to the media subsystem, but does not adjust the
entry in MAINTAINERS.

Hence, ./scripts/get_maintainer.pl --self-test=patterns complains about a
broken reference.

Repair this file reference in ZR36067 VIDEO FOR LINUX DRIVER.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: tuners: Remove the unneeded result variable
ye xingchen [Mon, 5 Sep 2022 09:02:03 +0000 (11:02 +0200)]
media: tuners: Remove the unneeded result variable

Return the value xc_send_i2c_data() directly instead of storing it in
another redundant variable.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: platform: mtk-mdp3: fix PM reference leak in mdp_comp_clock_on()
Sun Ke [Fri, 2 Sep 2022 08:58:19 +0000 (10:58 +0200)]
media: platform: mtk-mdp3: fix PM reference leak in mdp_comp_clock_on()

mdp_comp_clock_on will increase runtime PM usage counter,
and mdp_comp_clock_off will decrease the runtime PM usage counter.
so, if mdp_comp_clock_on failed after increment runtime PM usage
counter, it should decrease it before return a error code.

pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
Fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

And if failed to enable clk, add pm_runtime_put() to decrease the
runtime PM usage counter.

Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 driver")
Signed-off-by: Sun Ke <sunke32@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: platform: mtk-mdp3: fix error code in mdp_vpu_dev_init()
Dan Carpenter [Thu, 1 Sep 2022 14:47:48 +0000 (16:47 +0200)]
media: platform: mtk-mdp3: fix error code in mdp_vpu_dev_init()

Return a negative error code if mdp_vpu_shared_mem_alloc() fails.

Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: radio-si476x: Remove the unneeded result variable
ye xingchen [Thu, 1 Sep 2022 07:45:07 +0000 (09:45 +0200)]
media: radio-si476x: Remove the unneeded result variable

Return the value v4l2_fh_release() directly instead of storing it in
another redundant variable.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: docs: libv4l-introduction.rst: Fix function signature and link
Daniel Lundberg Pedersen [Wed, 31 Aug 2022 14:54:59 +0000 (16:54 +0200)]
media: docs: libv4l-introduction.rst: Fix function signature and link

v4l2_mmap returns a void*, also link to mmap instead of munmap

Signed-off-by: Daniel Lundberg Pedersen <dlp@qtec.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: platform: mtk-mdp3: add pointer checks and use devm_kfree
Moudy Ho [Wed, 31 Aug 2022 08:56:04 +0000 (10:56 +0200)]
media: platform: mtk-mdp3: add pointer checks and use devm_kfree

Fix two errors reported by smatch:
    drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c:292
        mdp_probe() error: we previously assumed 'mdp' could be null
    drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:460
        mdp_cmdq_send() error: we previously assumed 'cmd' could be null

Also, avoid warnings reported by smatch:
    drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c:872
        mdp_comp_create() warn: passing devm_ allocated variable to kfree. 'comp'

[hverkuil: fix devm_kfree call]

Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: si4713: Use the right include
Linus Walleij [Tue, 30 Aug 2022 21:28:06 +0000 (23:28 +0200)]
media: si4713: Use the right include

The driver includes the legacy <linux/gpio.h> header but uses
<linux/gpio/consumer.h>.

Cc: Dinesh Ram <Dinesh.Ram@cern.ch>
Cc: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: i2c: isl7998x: Use right include
Linus Walleij [Tue, 30 Aug 2022 21:11:10 +0000 (23:11 +0200)]
media: i2c: isl7998x: Use right include

This driver is using GPIO descriptors but uses the legacy
include header <linux/gpio.h>. Fix it by including the
intended <linux/gpio/consumer.h>.

Cc: Marek Vasut <marex@denx.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: cec: add support for Absolute Volume Control
Hans Verkuil [Tue, 30 Aug 2022 10:37:24 +0000 (12:37 +0200)]
media: cec: add support for Absolute Volume Control

Add support for this new CEC message. This was added in HDMI 2.1a.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: dvb-frontends/drxk: initialize err to 0
Hans Verkuil [Tue, 30 Aug 2022 05:59:24 +0000 (07:59 +0200)]
media: dvb-frontends/drxk: initialize err to 0

Fix a compiler warning:

drivers/media/dvb-frontends/drxk_hard.c: In function 'drxk_read_ucblocks':
drivers/media/dvb-frontends/drxk_hard.c:6673:21: warning: 'err' may be used uninitialized [-Wmaybe-uninitialized]
 6673 |         *ucblocks = (u32) err;
      |                     ^~~~~~~~~
drivers/media/dvb-frontends/drxk_hard.c:6663:13: note: 'err' was declared here
 6663 |         u16 err;
      |             ^~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: v4l2-ctrls: drop 'elems' argument from control type ops.
Hans Verkuil [Mon, 29 Aug 2022 14:05:14 +0000 (16:05 +0200)]
media: v4l2-ctrls: drop 'elems' argument from control type ops.

The type ops for equal, init and validate have an elems argument,
but this can be taken from struct v4l2_ctrl: ctrl->elems for
equal and init, and ctrl->new_elems for validate (since you are
validating a new control value).

So drop this argument and update all callers.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: amphion: release m2m ctx when releasing vpu instance
Ming Qian [Mon, 29 Aug 2022 05:33:16 +0000 (07:33 +0200)]
media: amphion: release m2m ctx when releasing vpu instance

release m2m ctx in the callback function that
release the vpu instance, then there is no need
to add lock around releasing m2m ctx.

Fixes: 3cd084519c6f ("media: amphion: add vpu v4l2 m2m support")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: coda: jpeg: drop coda9_jpeg_dec_huff_setup() return value
Philipp Zabel [Thu, 25 Aug 2022 10:41:49 +0000 (12:41 +0200)]
media: coda: jpeg: drop coda9_jpeg_dec_huff_setup() return value

coda9_jpeg_dec_huff_setup() never returns anything but 0. Drop
return value and superfluous error handling at the call site.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: pci/cx18: fix repeated words in comments
Jilin Yuan [Wed, 24 Aug 2022 13:27:42 +0000 (15:27 +0200)]
media: pci/cx18: fix repeated words in comments

Delete the redundant word 'is'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: usb/dvb-usb-v2: fix repeated words in comments
Jilin Yuan [Wed, 24 Aug 2022 13:13:50 +0000 (15:13 +0200)]
media: usb/dvb-usb-v2: fix repeated words in comments

Delete the redundant word 'my'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: usb/msi2500: fix repeated words in comments
Jilin Yuan [Wed, 24 Aug 2022 13:10:16 +0000 (15:10 +0200)]
media: usb/msi2500: fix repeated words in comments

Delete the redundant word 'for'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: cros-ec-cec: limit msg.len to CEC_MAX_MSG_SIZE
Hans Verkuil [Wed, 24 Aug 2022 07:06:19 +0000 (09:06 +0200)]
media: cros-ec-cec: limit msg.len to CEC_MAX_MSG_SIZE

I expect that the hardware will have limited this to 16, but just in
case it hasn't, check for this corner case.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: s5p_cec: limit msg.len to CEC_MAX_MSG_SIZE
Hans Verkuil [Wed, 24 Aug 2022 07:02:42 +0000 (09:02 +0200)]
media: s5p_cec: limit msg.len to CEC_MAX_MSG_SIZE

I expect that the hardware will have limited this to 16, but just in
case it hasn't, check for this corner case.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Zero v4l2_subdev_format fields in when validating links
Laurent Pinchart [Tue, 23 Aug 2022 15:11:36 +0000 (17:11 +0200)]
media: rkisp1: Zero v4l2_subdev_format fields in when validating links

The local sd_fmt variable in rkisp1_capture_link_validate() has
uninitialized fields, which causes random failures when calling the
subdev .get_fmt() operation. Fix it by initializing the variable when
declaring it, which zeros all other fields.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Configure LSC after enabling the ISP
Laurent Pinchart [Tue, 16 Aug 2022 23:53:57 +0000 (01:53 +0200)]
media: rkisp1: Configure LSC after enabling the ISP

The ISP8000Nano v18.02 (found in the i.MX8MP) requires the ISP to be
enabled (as indicated by the ISP_CTRL.ISP_ENABLE bit) to configure the
lens shading table in internal RAM. The driver currently configures all
ISP initial parameters before enabling the ISP, which causes the LSC RAM
to not be initialized properly.

To fix this, split the rkisp1_params_configure() function into a
rkisp1_params_pre_configure() and a rkisp1_params_post_configure(). The
former configures all ISP parameters but LSC, while the latter
configures LSC. To implement this, the rkisp1_params_apply_params_cfg()
function is deconstructed, with two small helpers created to deal with
the parameters buffers, which are then used in rkisp1_params_isr(),
rkisp1_params_pre_configure() and rkisp1_params_post_configure().

While this initialization ordering is only needed for the ISP8000Nano
v18.02, it doesn't affect other ISP versions negatively, and can thus be
followed unconditionally.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Use correct macro for gradient registers
Laurent Pinchart [Tue, 16 Aug 2022 23:53:57 +0000 (01:53 +0200)]
media: rkisp1: Use correct macro for gradient registers

The rkisp1_lsc_config() function incorrectly uses the
RKISP1_CIF_ISP_LSC_SECT_SIZE() macro for the gradient registers. Replace
it with the correct macro, and rename it from
RKISP1_CIF_ISP_LSC_GRAD_SIZE() to RKISP1_CIF_ISP_LSC_SECT_GRAD() as the
corresponding registers store the gradients for each sector, not a size.
This doesn't cause any functional change as the two macros are defined
identically (the size and gradient registers store fields in the same
number of bits at the same positions).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Simplify LSC x/y size and grad register macros
Laurent Pinchart [Tue, 16 Aug 2022 23:53:57 +0000 (01:53 +0200)]
media: rkisp1: Simplify LSC x/y size and grad register macros

The LSC module x/y size and grad configuration is stored in a set of 4
indexed registers each. The rkisp1-regs.h header defines all those
registers, but only the first one in each set is used, with manual
calculation of addresses of subsequent registers. Simplifies this by
merging all 4 register macros into one that takes the index as a
parameter. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Store LSC register values in u32 variables
Laurent Pinchart [Tue, 16 Aug 2022 23:53:57 +0000 (01:53 +0200)]
media: rkisp1: Store LSC register values in u32 variables

Use the u32 type instead of unsigned int to store register values in the
LSC configuration code, to make the variables' size more explicit. No
functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Clean up LSC configuration code
Laurent Pinchart [Tue, 16 Aug 2022 23:53:57 +0000 (01:53 +0200)]
media: rkisp1: Clean up LSC configuration code

Clean up the LSC configuration code to improve its readability by
shortening lines, using extra local variables and renaming long
variables. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Allow setting color space on resizer sink pad
Laurent Pinchart [Fri, 12 Aug 2022 22:44:14 +0000 (00:44 +0200)]
media: rkisp1: Allow setting color space on resizer sink pad

The resizer doesn't deal with color spaces, so it can accept any color
space on its input, and propagates it unchanged to its output. When
operating with a Bayer input format (in pass-through mode) further
restrict the YCbCr encoding and quantization to Rec 601 and full range
respectively, as for raw data the former ought to be ignored and the
latter is always full range.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Initialize color space on resizer sink and source pads
Laurent Pinchart [Fri, 12 Aug 2022 22:44:14 +0000 (00:44 +0200)]
media: rkisp1: Initialize color space on resizer sink and source pads

Initialize the four color space fields on the sink and source video pads
of the resizer in the .init_cfg() operation. The resizer can't perform
any color space conversion, so set the sink and source color spaces to
the same defaults, which match the ISP source video pad default.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Configure CSM based on YCbCr encoding
Laurent Pinchart [Fri, 12 Aug 2022 22:44:14 +0000 (00:44 +0200)]
media: rkisp1: Configure CSM based on YCbCr encoding

The driver currently only implements the Rec. 601 YCbCr encoding, extend
it with support for the other encodings defined by V4L2 (Rec. 709, Rec.
2020 and SMPTE240m). The coefficients have been calculated by rounding
the floating point values to the nearest Q1.7 fixed-point value,
adjusting the rounding to ensure that the sum of each line in the matrix
is preserved to avoid overflows.

At the hardware level, the RGB to YUV conversion matrix is fully
configurable, custom encoding could be supported by extending the ISP
parameters if desired.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Don't pass the quantization to rkisp1_csm_config()
Laurent Pinchart [Fri, 12 Aug 2022 22:44:14 +0000 (00:44 +0200)]
media: rkisp1: Don't pass the quantization to rkisp1_csm_config()

The rkisp1_csm_config() function takes a pointer to the rkisp1_params
structure which contains the quantization value. There's no need to pass
it separately to the function. Drop it from the function parameters.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Configure quantization using ISP source pad
Laurent Pinchart [Fri, 12 Aug 2022 22:44:14 +0000 (00:44 +0200)]
media: rkisp1: Configure quantization using ISP source pad

The rkisp1_config_isp() function uses the format on the sink pad of the
ISP to configure quantization at the output of the ISP. This is
incorrect, as hinted by the src_frm variable name that stores the
format. Fix it by using the source pad.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Allow setting all color space fields on ISP source pad
Laurent Pinchart [Fri, 12 Aug 2022 22:56:22 +0000 (00:56 +0200)]
media: rkisp1: Allow setting all color space fields on ISP source pad

The ISP output color space is configured through the ISP source pad. At
the moment, only the quantization can be set. Extend it to the three
other color space fields:

- The ycbcr_enc field will be used to configure the RGB to YUV matrix
  (currently hardcoded to Rec. 601).

- The colorspace (which controls the color primaries) and xfer_func
  fields will not be used to configure the ISP, as the corresponding
  hardware blocks (the cross-talk RGB to RGB matrix and the tone mapping
  curve) are programmed directly by applications through ISP parameters.
  Nonetheless, those two fields should be set by applications to match
  the ISP configuration, in order to propagate the correct color space
  down the pipeline up to the capture video nodes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Fix source pad format configuration
Laurent Pinchart [Fri, 12 Aug 2022 22:44:14 +0000 (00:44 +0200)]
media: rkisp1: Fix source pad format configuration

The ISP converts Bayer data to YUV when operating normally, and can also
operate in pass-through mode where the input and output formats must
match. Converting from YUV to Bayer isn't possible. If such an invalid
configuration is attempted, adjust it by copying the sink pad media bus
code to the source pad.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Allow setting color space on ISP sink pad
Laurent Pinchart [Fri, 12 Aug 2022 22:44:14 +0000 (00:44 +0200)]
media: rkisp1: Allow setting color space on ISP sink pad

The ISP accepts different color spaces on its input: for YUV input, it
doesn't set any restrictions, and for Bayer inputs, any color primaries
or transfer function can be accepted (YCbCr encoding isn't applicable
there, and quantization range can only be full).

Allow setting a color space on the ISP sink pad, with the aforementioned
restrictions. The settings don't influence hardware yet (only the YUV
quantization range will, anything else has no direct effect on the ISP
configuration), but can already be set to allow color space information
to be coherent across the ISP sink link.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rkisp1: Initialize color space on ISP sink and source pads
Laurent Pinchart [Fri, 12 Aug 2022 22:44:14 +0000 (00:44 +0200)]
media: rkisp1: Initialize color space on ISP sink and source pads

Initialize the four color space fields on the sink and source video pads
of the ISP in the .init_cfg() operation. As the main use case for the
ISP is to convert Bayer data to YUV, select a raw color space on the
sink pad and a limited range quantization of SYCC on the source pad by
default.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rockchip: rkisp1: Define macros for DPCC configurations in UAPI
Laurent Pinchart [Thu, 9 Jun 2022 10:31:13 +0000 (12:31 +0200)]
media: rockchip: rkisp1: Define macros for DPCC configurations in UAPI

Extend the UAPI rkisp1-config.h header with macros for all DPCC
configuration fields. While at it, clarify of fix issues in the DPCC
documentation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rockchip: rkisp1: Mask invalid bits in DPCC parameters
Laurent Pinchart [Thu, 9 Jun 2022 10:31:13 +0000 (12:31 +0200)]
media: rockchip: rkisp1: Mask invalid bits in DPCC parameters

Restrict the DPCC configuration that can be set by userspace to valid
register bits. To do so, reorganize the related register macros to
define valid bitmasks, as well as bits of the DPCC mode register.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: rockchip: rkisp1: Set DPCC methods enable bits inside loop
Laurent Pinchart [Thu, 9 Jun 2022 10:31:13 +0000 (12:31 +0200)]
media: rockchip: rkisp1: Set DPCC methods enable bits inside loop

The rkisp1_dpcc_config() function looks over methods sets to configure
them, but sets the RKISP1_CIF_ISP_DPCC_METHODS_SET_* registers outside
of the loop with hand-unrolled code. Move this to the loop to simplify
the code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mceusb: set timeout to at least timeout provided
Sean Young [Fri, 2 Sep 2022 10:32:21 +0000 (12:32 +0200)]
media: mceusb: set timeout to at least timeout provided

By rounding down, the actual timeout can be lower than requested. As a
result, long spaces just below the requested timeout can be incorrectly
reported as timeout and truncated.

Fixes: 877f1a7cee3f ("media: rc: mceusb: allow the timeout to be configurable")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: imon: Remove the unneeded result variable
ye xingchen [Tue, 30 Aug 2022 08:30:27 +0000 (10:30 +0200)]
media: imon: Remove the unneeded result variable

Return the value send_packet() directly instead of storing it in another
redundant variable.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: mceusb: Use new usb_control_msg_*() routines
Alan Stern [Fri, 26 Aug 2022 19:31:40 +0000 (21:31 +0200)]
media: mceusb: Use new usb_control_msg_*() routines

Automatic kernel fuzzing led to a WARN about invalid pipe direction in
the mceusb driver:

------------[ cut here ]------------
usb 6-1: BOGUS control dir, pipe 80000380 doesn't match bRequestType 40
WARNING: CPU: 0 PID: 2465 at drivers/usb/core/urb.c:410
usb_submit_urb+0x1326/0x1820 drivers/usb/core/urb.c:410
Modules linked in:
CPU: 0 PID: 2465 Comm: kworker/0:2 Not tainted 5.19.0-rc4-00208-g69cb6c6556ad #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.13.0-1ubuntu1.1 04/01/2014
Workqueue: usb_hub_wq hub_event
RIP: 0010:usb_submit_urb+0x1326/0x1820 drivers/usb/core/urb.c:410
Code: 7c 24 40 e8 ac 23 91 fd 48 8b 7c 24 40 e8 b2 70 1b ff 45 89 e8
44 89 f1 4c 89 e2 48 89 c6 48 c7 c7 a0 30 a9 86 e8 48 07 11 02 <0f> 0b
e9 1c f0 ff ff e8 7e 23 91 fd 0f b6 1d 63 22 83 05 31 ff 41
RSP: 0018:ffffc900032becf0 EFLAGS: 00010282
RAX: 0000000000000000 RBX: ffff8881100f3058 RCX: 0000000000000000
RDX: ffffc90004961000 RSI: ffff888114c6d580 RDI: fffff52000657d90
RBP: ffff888105ad90f0 R08: ffffffff812c3638 R09: 0000000000000000
R10: 0000000000000005 R11: ffffed1023504ef1 R12: ffff888105ad9000
R13: 0000000000000040 R14: 0000000080000380 R15: ffff88810ba96500
FS: 0000000000000000(0000) GS:ffff88811a800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffe810bda58 CR3: 000000010b720000 CR4: 0000000000350ef0
Call Trace:
<TASK>
usb_start_wait_urb+0x101/0x4c0 drivers/usb/core/message.c:58
usb_internal_control_msg drivers/usb/core/message.c:102 [inline]
usb_control_msg+0x31c/0x4a0 drivers/usb/core/message.c:153
mceusb_gen1_init drivers/media/rc/mceusb.c:1431 [inline]
mceusb_dev_probe+0x258e/0x33f0 drivers/media/rc/mceusb.c:1807

The reason for the warning is clear enough; the driver sends an
unusual read request on endpoint 0 but does not set the USB_DIR_IN bit
in the bRequestType field.

More importantly, the whole situation can be avoided and the driver
simplified by converting it over to the relatively new
usb_control_msg_recv() and usb_control_msg_send() routines.  That's
what this fix does.

Reported-and-tested-by: Rondreis <linhaoguo86@gmail.com>
Link: https://lore.kernel.org/all/CAB7eexLLApHJwZfMQ=X-PtRhw0BgO+5KcSMS05FNUYejJXqtSA@mail.gmail.com/
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable@vger.kernel.org
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: remove reference to CONFIG_EMBEDDED in MEDIA_SUPPORT_FILTER
Lukas Bulwahn [Thu, 8 Sep 2022 10:43:34 +0000 (12:43 +0200)]
media: remove reference to CONFIG_EMBEDDED in MEDIA_SUPPORT_FILTER

The config EMBEDDED selects EXPERT, i.e., when EMBEDDED is enabled, EXPERT
is usually also enabled. Hence, it sufficient to have the option
MEDIA_SUPPORT_FILTER set to y if !EXPERT.

This way, MEDIA_SUPPORT_FILTER does not refer to CONFIG_EMBEDDED anymore
and allows us to remove CONFIG_EMBEDDED in the close future.

Remove the reference to CONFIG_EMBEDDED in MEDIA_SUPPORT_FILTER.

Link: https://lore.kernel.org/linux-media/20220908104337.11940-4-lukas.bulwahn@gmail.com
Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: destage Hantro VPU driver
Ezequiel Garcia [Mon, 18 Jul 2022 21:41:21 +0000 (23:41 +0200)]
media: destage Hantro VPU driver

The Hantro mainline driver has been used in production
since several years and was only kept as a staging driver
due the stateless CODEC controls.

Now that all the stateless CODEC controls have been moved
out of staging, graduate the driver as well.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: platform: mtk-mdp3: add MediaTek MDP3 driver
Moudy Ho [Tue, 23 Aug 2022 02:38:03 +0000 (04:38 +0200)]
media: platform: mtk-mdp3: add MediaTek MDP3 driver

This patch adds driver for MediaTek's Media Data Path ver.3 (MDP3).
It provides the following functions:
  color transform, format conversion, resize, crop, rotate, flip
  and additional image quality enhancement.

The MDP3 driver is mainly used for Google Chromebook products to
import the new architecture to set the HW settings as shown below:
  User -> V4L2 framework
    -> MDP3 driver -> SCP (setting calculations)
      -> MDP3 driver -> CMDQ (GCE driver) -> HW

Each modules' related operation control is sited in mtk-mdp3-comp.c
Each modules' register table is defined in file with "mdp_reg_" prefix
GCE related API, operation control  sited in mtk-mdp3-cmdq.c
V4L2 m2m device functions are implemented in mtk-mdp3-m2m.c
Probe, power, suspend/resume, system level functions are defined in
mtk-mdp3-core.c

[hverkuil: add 'depends on REMOTEPROC']

Signed-off-by: Ping-Hsun Wu <ping-hsun.wu@mediatek.com>
Signed-off-by: daoyuan huang <daoyuan.huang@mediatek.com>
Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: dt-binding: mediatek: add bindings for MediaTek CCORR and WDMA
Moudy Ho [Tue, 23 Aug 2022 02:38:01 +0000 (04:38 +0200)]
media: dt-binding: mediatek: add bindings for MediaTek CCORR and WDMA

This patch adds DT binding documentation for MediaTek's CCORR and
WDMA components.
These components exist in both MediaTek's Media Data Path 3(MDP3) and DRM,
and the bindings are placed under the folder "./soc/mediatek" to prevent
duplicate builds.

Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: dt-binding: mediatek: add bindings for MediaTek MDP3 components
Moudy Ho [Tue, 23 Aug 2022 02:38:00 +0000 (04:38 +0200)]
media: dt-binding: mediatek: add bindings for MediaTek MDP3 components

This patch adds DT binding documents for Media Data Path 3 (MDP3)
a unit in multimedia system combined with several components and
used for scaling and color format convert.

Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: xilinx: vipp: Fix refcount leak in xvip_graph_dma_init
Miaoqian Lin [Wed, 1 Jun 2022 04:25:14 +0000 (06:25 +0200)]
media: xilinx: vipp: Fix refcount leak in xvip_graph_dma_init

of_get_child_by_name() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: df3305156f98 ("[media] v4l: xilinx: Add Xilinx Video IP core")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: xilinx: video: Add 1X12 greyscale format
Volodymyr Kharuk [Thu, 14 Jul 2022 08:34:44 +0000 (10:34 +0200)]
media: xilinx: video: Add 1X12 greyscale format

Extend the xilinx video driver with Y12_1X12 greyscale format

Signed-off-by: Volodymyr Kharuk <vkh@melexis.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: xilinx: csi2rxss: Add 1X12 greyscale format
Volodymyr Kharuk [Thu, 14 Jul 2022 08:34:43 +0000 (10:34 +0200)]
media: xilinx: csi2rxss: Add 1X12 greyscale format

Extend the csi2rxss with Y12_1X12 greyscale format

Signed-off-by: Volodymyr Kharuk <vkh@melexis.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: staging: media: imx: imx7-media-csi: Increase video mem limit
Petko Manolov [Sat, 9 Jul 2022 07:31:00 +0000 (09:31 +0200)]
media: staging: media: imx: imx7-media-csi: Increase video mem limit

Some high resolution (like Sony IMX492 47Mpix) sensors requre large amount space
for buffering.  64MB is far from sufficient so this patch increases the limit to
512MB.

Signed-off-by: Petko Manolov <petko.manolov@konsulko.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: uvcvideo: Limit power line control for Sonix Technology
huanglei [Sat, 20 Aug 2022 00:56:58 +0000 (02:56 +0200)]
media: uvcvideo: Limit power line control for Sonix Technology

The device does not implement the power line control correctly. Add a
corresponding control mapping override.

Bus 003 Device 003: ID 3277:0072 Sonix Technology Co., Ltd. USB 2.0 Camera
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x3277
  idProduct          0x0072
  bcdDevice            1.00
  iManufacturer           2 Sonix Technology Co., Ltd.
  iProduct                1 USB 2.0 Camera
  iSerial                 3 REV0001
  bNumConfigurations      1

Signed-off-by: huanglei <huanglei@kylinos.cn>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: uvcvideo: Use entity get_cur in uvc_ctrl_set
Yunke Cao [Thu, 7 Jul 2022 08:53:31 +0000 (10:53 +0200)]
media: uvcvideo: Use entity get_cur in uvc_ctrl_set

Entity controls should get_cur using an entity-defined function
instead of via a query. Fix this in uvc_ctrl_set.

Fixes: 65900c581d01 ("media: uvcvideo: Allow entity-defined get_info and get_cur")
Signed-off-by: Yunke Cao <yunkec@google.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: uvcvideo: Fix typo 'the the' in comment
Slark Xiao [Fri, 22 Jul 2022 07:13:43 +0000 (09:13 +0200)]
media: uvcvideo: Fix typo 'the the' in comment

Replace 'the the' with 'the' in the comment.

Signed-off-by: Slark Xiao <slark_xiao@163.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
22 months agomedia: uvcvideo: Use indexed loops in uvc_ctrl_init_ctrl()
Laurent Pinchart [Mon, 18 Jul 2022 11:56:54 +0000 (13:56 +0200)]
media: uvcvideo: Use indexed loops in uvc_ctrl_init_ctrl()

As shown by the bug introduced in commit 86f7ef773156 ("media: uvcvideo:
Add support for per-device control mapping overrides"), the loop style
used by uvc_ctrl_init_ctrl() is error-prone. Rewrite the loops to use
indices instead.

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>
22 months agomedia: uvcvideo: Fix memory leak in uvc_gpio_parse
José Expósito [Sat, 8 Jan 2022 17:04:39 +0000 (18:04 +0100)]
media: uvcvideo: Fix memory leak in uvc_gpio_parse

Previously the unit buffer was allocated before checking the IRQ for
privacy GPIO. In case of error, the unit buffer was leaked.

Allocate the unit buffer after the IRQ to avoid it.

Addresses-Coverity-ID: 1474639 ("Resource leak")

Fixes: 2886477ff987 ("media: uvcvideo: Implement UVC_EXT_GPIO_UNIT")
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>