platform/kernel/linux-starfive.git
2 years agomedia: staging: media: imx: imx7-media-csi: Drop error message on alloc failure
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Drop error message on alloc failure

The kernel memory allocators already complain loudly to the log when
allocation fails. There's no need for an additional message.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Decouple from shared macros
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Decouple from shared macros

Decouple from the IMX7_CSI_VIDEO_DEF_PIX_WIDTH,
IMX7_CSI_VIDEO_DEF_PIX_HEIGHT and IMX_MEDIA_EOF_TIMEOUT macros defined
in shared helpers by duplicating them in the imx7-media-csi driver, with
a rename to avoid name clashes. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Decouple from imx_media_dma_buf
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Decouple from imx_media_dma_buf

Decouple from the imx_media_dma_buf structure defined in shared helpers
by duplicating it in the imx7-media-csi driver, along with the two small
alloc and free functions. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Store imx7_csi in drv data
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Store imx7_csi in drv data

Replace the subdev pointer stored in platform drv data with the imx7_csi
pointer. Drop a now redundant dev_set_drvdata() call.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Fold imx_media_video_dev into imx7_csi
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Fold imx_media_video_dev into imx7_csi

Now that the driver doesn't use any helper that relies on the
imx_media_video_dev structure anymore, merge its fields directly in the
imx7_csi structure. Update all the users accordingly, and drop the list
field that isn't used by the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Decouple from imx_media_buffer
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Decouple from imx_media_buffer

Decouple from the imx_media_buffer structure defined in shared helpers
by duplicating it in the imx7-media-csi driver. No functional change
intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Fold imx_media_dev into imx7_csi
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Fold imx_media_dev into imx7_csi

Now that the driver doesn't use any helper that relies on the
imx_media_dev structure anymore, merge the three fields of the
imx_media_dev structure directly in the imx7_csi structure. Update all
the users accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Inline pipeline start/stop
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Inline pipeline start/stop

The imx7_csi_media_pipeline_set_stream() function has separate branches
for the start and stop paths, surrounded by mutex lock/unlock. That is
very little shared code, inline the locking and corresponding branch in
each of the two callers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Avoid unnecessary casts
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Avoid unnecessary casts

Simplify the imx7_csi_media_pipeline_set_stream() function by passing it
the imx7_csi pointer, which avoids going from subdev to entity and back
to subdev.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Import imx_media_pipeline_set_stream()
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Import imx_media_pipeline_set_stream()

To prepare for code refactoring, copy the
imx_media_pipeline_set_stream() helper used by this driver from
imx-media-utils.c. Rename the function to avoid name clashes, no
functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Inline imx_media_pipeline_pad()
Laurent Pinchart [Tue, 10 May 2022 00:37:01 +0000 (01:37 +0100)]
media: staging: media: imx: imx7-media-csi: Inline imx_media_pipeline_pad()

Inline the imx_media_pipeline_pad() helper, dropping all the code unused
by the imx7-media-csi driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Don't initialize unused fields
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Don't initialize unused fields

The imx_media_dev structure contains three fields that are not used by
this driver or any helper code that it calls. Don't initialize them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop imx_media_add_video_device call
Laurent Pinchart [Tue, 10 May 2022 00:25:26 +0000 (01:25 +0100)]
media: staging: media: imx: imx7-media-csi: Drop imx_media_add_video_device call

There's no need to call imx_media_add_video_device() anymore, as the
video devices list it manages is only used by the control inheritance
mechanism in the helpers, which this driver doesn't use.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Embed imx_media_dev in imx7_csi
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Embed imx_media_dev in imx7_csi

There's no need anymore to allocate the imx_media_dev structure
separately from imx7_csi. Embed it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Import imx_media_dev_init() helper
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Import imx_media_dev_init() helper

To prepare for code refactoring, copy the imx_media_dev_init() helper
used by this driver from imx-media-dev-common.c. Rename the function to
avoid name clashes, and leave the v4l2_device notify handler out as it
only serves to implement control inheritance, which this driver doesn't
use. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Don't set subdev group id
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Don't set subdev group id

The subdev group id isn't used by any of the remaining helpers used by
this driver, don't set it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Ensure consistent function prefix
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Ensure consistent function prefix

Rename all the functions and macros imported from imx-media-capture.c
with a consistent imx7_csi_video_ prefix. No functional change intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Fold capture_priv into imx7_csi
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Fold capture_priv into imx7_csi

Merge the capture_priv fields in the imx7_csi structure as there's no
more need to have two separate structures. Update all the users
accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Reorganize imx7_csi structure
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Reorganize imx7_csi structure

The struct imx7_csi fields are in a random order, reorganize them
logically to prepare for adding new fields.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop unused controls support
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Drop unused controls support

Drop the unused control handler from the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop legacy video device support
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Drop legacy video device support

Drop all the code related to the unused (by this driver) legacy video
device support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Import video device helpers
Laurent Pinchart [Mon, 9 May 2022 22:32:33 +0000 (23:32 +0100)]
media: staging: media: imx: imx7-media-csi: Import video device helpers

To prepare for code refactoring, copy the video device helper code used
by this driver verbatim from imx-media-capture. Rename some functions to
avoid name clashes, and leave the legacy ioctls out as they're not used
by the imx7-media-csi driver. No functional change included.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Remove imx_media_of_add_csi
Paul Elder [Fri, 6 May 2022 11:36:58 +0000 (12:36 +0100)]
media: staging: media: imx: imx7-media-csi: Remove imx_media_of_add_csi

imx_media_of_add_csi() from imx-media-of.c validates that the fwnode for
the CSI bridge is enabled, and adds the fwnode to the async notifier of
the imxmd. The former is redundant, as if the CSI bridge driver probes,
clearly it is enabled in the DT. The latter is not needed as the imxmd
notifier isn't used anymore. The call is thus not needed and can be
dropped. This removes the dependency of imx7-media-csi.c on
imx-media-of.c.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Move format init to probe time
Laurent Pinchart [Sun, 6 Feb 2022 05:13:53 +0000 (05:13 +0000)]
media: staging: media: imx: imx7-media-csi: Move format init to probe time

There's no need to wait until the subdev is registered to initialize the
active pad formats. Do so at probe time.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop unused frame_interval
Laurent Pinchart [Sun, 6 Feb 2022 05:13:53 +0000 (05:13 +0000)]
media: staging: media: imx: imx7-media-csi: Drop unused frame_interval

The frame_interval field of the imx7_csi structure is set but never
used. Drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Don't populate vdev lists
Laurent Pinchart [Sun, 6 Feb 2022 05:13:53 +0000 (05:13 +0000)]
media: staging: media: imx: imx7-media-csi: Don't populate vdev lists

The imx_media_dev framework maintains a per-pad list of connected video
devices, created once all subdevs have been bound. This is used for two
purposes, updating V4L2 control inheritance when links change, and
relaying subdev events to video nodes. None of these are used by the
imx7-media-csi driver as it implements the MC-centric approach. Drop
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Move misc init out of probe()
Paul Elder [Thu, 5 May 2022 12:48:33 +0000 (13:48 +0100)]
media: staging: media: imx: imx7-media-csi: Move misc init out of probe()

There is a chunk of miscellaneous initializations related to the CSI
subdev and media pads directly in the probe function. Move them into the
imx7_csi_media_init() function to clean up the probe function.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop the imx_media notifier
Laurent Pinchart [Sun, 6 Feb 2022 05:13:53 +0000 (05:13 +0000)]
media: staging: media: imx: imx7-media-csi: Drop the imx_media notifier

The V4L2 async notifier embedded in the imx_media_dev structure is
triggered when the CSI bridge subdev is registered. We don't need an
async notifier for this, as we can call the .complete() handler directly
from the CSI bridge subdev .registered() handler.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Drop duplicate link creation
Laurent Pinchart [Sun, 6 Feb 2022 05:13:53 +0000 (05:13 +0000)]
media: staging: media: imx: imx7-media-csi: Drop duplicate link creation

The imx_media_create_csi2_links() creates a media controller link
between the CSI-2 receiver and the next entity in the pipeline, which
can be either a video mux (handled by the video-mux driver) or the CSI
bridge itself. This isn't needed, as the link is already created either
by the video-mux driver or by the imx7-media-csi driver itself (in
imx7_csi_notify_bound()).

Drop imx_media_create_csi2_links(), which allows dropping the CSI bridge
subdev grp_id.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Import notifier helpers
Laurent Pinchart [Sun, 6 Feb 2022 05:13:53 +0000 (05:13 +0000)]
media: staging: media: imx: imx7-media-csi: Import notifier helpers

To prepare for code refactoring, copy the V4L2 async notifier helper
code used by this driver verbatim from imx-media-dev-common.c. Rename
some functions to avoid name clashes. No functional change included.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Split imx_media_dev from probe()
Laurent Pinchart [Sat, 5 Feb 2022 04:16:36 +0000 (04:16 +0000)]
media: staging: media: imx: imx7-media-csi: Split imx_media_dev from probe()

Prepare for the decoupling of the imx7-media-csi driver from the
IPUv3-based drivers by moving the imx_media_dev handling from probe()
function to separate functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: imx: imx7-media-csi: Initialize locks early on
Laurent Pinchart [Sat, 5 Feb 2022 04:16:36 +0000 (04:16 +0000)]
media: staging: media: imx: imx7-media-csi: Initialize locks early on

Group all the direct initialization of imx7_csi fields at the beginning
of the imx7_csi_probe() function instead of spreading them around.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: renesas: rcar_drif: Drop of_match_ptr()
Laurent Pinchart [Wed, 25 May 2022 09:16:04 +0000 (10:16 +0100)]
media: renesas: rcar_drif: Drop of_match_ptr()

The device_driver structure's of_match_table field exists
unconditionally, so there's no need for of_match_ptr(). This fixes a
compiler warning when test-compiling on non-OF platforms:

drivers/media/platform/renesas/rcar_drif.c:1470:34: warning: unused variable 'rcar_drif_of_table' [-Wunused-const-variable]
static const struct of_device_id rcar_drif_of_table[] = {
                                 ^

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: xilinx: Drop unexpected word 'with' in comments
Jiang Jian [Thu, 23 Jun 2022 12:29:48 +0000 (13:29 +0100)]
media: xilinx: Drop unexpected word 'with' in comments

There is an unexpected word 'with' in the comments that need to be
dropped.

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mt9p031: Move open subdev op init code into init_cfg
Marek Vasut [Sat, 18 Jun 2022 23:54:43 +0000 (00:54 +0100)]
media: mt9p031: Move open subdev op init code into init_cfg

The .open subdev op is not always called soon enough to initialize
the default crop settings. Move all this initialization into .init_cfg
op instead.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mt9p031: Add MT9P006 compatible
Marek Vasut [Sat, 18 Jun 2022 22:22:55 +0000 (23:22 +0100)]
media: mt9p031: Add MT9P006 compatible

Add compatible for MT9P006 sensor, which is older variant of MT9P031
and compatible with this driver.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-bindings: mt9p031: Add MT9P006 compatible string
Marek Vasut [Sat, 18 Jun 2022 22:22:54 +0000 (23:22 +0100)]
media: dt-bindings: mt9p031: Add MT9P006 compatible string

Add compatible for MT9P006 sensor, which is older variant of MT9P031
and compatible with this driver.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging/media/atomisp/pci/atomisp: Fix typo in string
Li zeming [Mon, 4 Jul 2022 02:28:07 +0000 (03:28 +0100)]
media: staging/media/atomisp/pci/atomisp: Fix typo in string

Remove the repeated ',' from string

Link: https://lore.kernel.org/linux-media/20220704022807.3215-1-zeming@nfschina.com
Signed-off-by: Li zeming <zeming@nfschina.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: clean up for-loop, remove redundant assignment to variable i
Colin Ian King [Tue, 28 Jun 2022 15:24:51 +0000 (16:24 +0100)]
media: atomisp: clean up for-loop, remove redundant assignment to variable i

There is a for-loop that initializes variable i but does not use it; the
assignment is redundant and can be removed. The proceeding assignment to
pointer fw can also be moved into the for-loop to clean up the code.

Link: https://lore.kernel.org/linux-media/20220628152451.184416-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media/atomisp: use max() impl
Karthik Alapati [Wed, 22 Jun 2022 16:39:00 +0000 (17:39 +0100)]
media: staging: media/atomisp: use max() impl

fix a coccinelle warning by replacing opencoded max()
implementation with max()

WARNING opportunity for max()

Link: https://lore.kernel.org/linux-media/YrNFpF2qvTxpZP8e@karthik-strix-linux.karthek.com
Signed-off-by: Karthik Alapati <mail@karthek.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: Fix typo in comments
Jiang Jian [Wed, 22 Jun 2022 14:34:42 +0000 (15:34 +0100)]
media: atomisp: Fix typo in comments

Remove the repeated word 'and' from comments

file: drivers/staging/media/atomisp/pci/hive_isp_css_include/host/debug_public.h
line: 28

* The buffer has a remote and and a local store

changed to:

* The buffer has a remote and a local store

Link: https://lore.kernel.org/linux-media/20220622143442.16942-1-jiangjian@cdjrlc.com
Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp_gmin_platform: stop abusing efivar API
Ard Biesheuvel [Mon, 20 Jun 2022 10:08:19 +0000 (11:08 +0100)]
media: atomisp_gmin_platform: stop abusing efivar API

As the code comment already suggests, using the efivar API in this way
is not how it is intended, and so let's switch to the right one, which
is simply to call efi.get_variable() directly after checking whether or
not the GetVariable() runtime service is supported.

Link: https://lore.kernel.org/linux-media/20220620100819.1682995-1-ardb@kernel.org
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: fix -Wdangling-pointer warning
Hans de Goede [Sun, 12 Jun 2022 16:05:56 +0000 (17:05 +0100)]
media: atomisp: fix -Wdangling-pointer warning

ia_css_rmgr_acq_vbuf() uses a local on stack
"struct ia_css_rmgr_vbuf_handle v" variable.

When this path using this is hit, either the rmgr_pop_handle() call
will make *handle point to another vbuf-handle, or because
v.count == 0, ia_css_rmgr_refcount_retain_vbuf() will alloc a new
vbuf-handle and make *handle point to it.

So on leaving the function *handle will never point to the on stack
vbuf-handle, but gcc does not know this and emits the following:

drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c: In function ‘ia_css_rmgr_acq_vbuf’:
drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c:276:33: warning: storing the address of local variable ‘h’ in ‘*handle’ [-Wdangling-pointer=]
  276 |                         *handle = &h;
      |                         ~~~~~~~~^~~~
drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c:257:40: note: ‘h’ declared here
  257 |         struct ia_css_rmgr_vbuf_handle h;
      |                                        ^
drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c:257:40: note: ‘handle’ declared here

Rework the code using a new_handle helper to suppress this
false-postive compiler warning.

Link: https://lore.kernel.org/linux-media/20220612160556.108264-4-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: fix uninitialized stack mem usage in ia_css_rmgr_acq_vbuf()
Hans de Goede [Sun, 12 Jun 2022 16:05:55 +0000 (17:05 +0100)]
media: atomisp: fix uninitialized stack mem usage in ia_css_rmgr_acq_vbuf()

When ia_css_rmgr_acq_vbuf() enters the code path where it uses the local
"struct ia_css_rmgr_vbuf_handle v" on the stack it relies on v.count==0
so that ia_css_rmgr_refcount_retain_vbuf allocates a new handle.

Explicitly set v.count to 0 rather then it being whatever was on the stack.

Link: https://lore.kernel.org/linux-media/20220612160556.108264-3-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: revert "don't pass a pointer to a local variable"
Hans de Goede [Sun, 12 Jun 2022 16:05:54 +0000 (17:05 +0100)]
media: atomisp: revert "don't pass a pointer to a local variable"

The gcc is warning about returning a pointer to a local variable
is a false positive.

The type of handle is "struct ia_css_rmgr_vbuf_handle **" and
"h.vptr" is left to NULL, so the "if ((*handle)->vptr == 0x0)"
check always succeeds when the "*handle = &h;" statement which
gcc warns about executes. Leading to this statement being executed:

rmgr_pop_handle(pool, handle);

If that succeeds,  then *handle has been set to point to one of
the pre-allocated array of handles, so it no longer points to h.

If that fails the following statement will be executed:

/* Note that handle will change to an internally maintained one */
ia_css_rmgr_refcount_retain_vbuf(handle);

Which allocated a new handle from the array of pre-allocated handles
and then makes *handle point to this. So the address of h is actually
never returned.

The fix for the false-postive compiler warning actually breaks the code,
the new:

**handle = h;

is part of a "if (pool->copy_on_write) { ... }" which means that the
handle where *handle points to should be treated read-only, IOW
**handle must never be set, instead *handle must be set to point to
a new handle (with a copy of the contents of the old handle).

The old code correctly did this and the new fixed code gets this wrong.

Note there is another patch in this series, which fixes the warning
in another way.

Link: https://lore.kernel.org/linux-media/20220612160556.108264-2-hdegoede@redhat.com
Fixes: fa1451374ebf ("media: atomisp: don't pass a pointer to a local variable")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp-mt9m114: Fix pointer dereferenced before checking
Haowen Bai [Mon, 30 May 2022 07:58:01 +0000 (08:58 +0100)]
media: atomisp-mt9m114: Fix pointer dereferenced before checking

The info->data is dereferencing before null checking, so move
it after checking.

Link: https://lore.kernel.org/linux-media/1653897481-25681-1-git-send-email-baihaowen@meizu.com
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: [PATCH] pci: atomisp_cmd: fix three missing checks on list iterator
Xiaomeng Tong [Thu, 14 Apr 2022 04:14:15 +0000 (05:14 +0100)]
media: [PATCH] pci: atomisp_cmd: fix three missing checks on list iterator

The three bugs are here:
__func__, s3a_buf->s3a_data->exp_id);
__func__, md_buf->metadata->exp_id);
__func__, dis_buf->dis_data->exp_id);

The list iterator 's3a_buf/md_buf/dis_buf' will point to a bogus
position containing HEAD if the list is empty or no element is found.
This case must be checked before any use of the iterator, otherwise
it will lead to a invalid memory access.

To fix this bug, add an check. Use a new variable '*_iter' as the
list iterator, while use the old variable '*_buf' as a dedicated
pointer to point to the found element.

Link: https://lore.kernel.org/linux-media/20220414041415.3342-1-xiam0nd.tong@gmail.com
Cc: stable@vger.kernel.org
Fixes: ad85094b293e4 ("Revert "media: staging: atomisp: Remove driver"")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: atomisp: Use kmap_local_page() in hmm_store()
Fabio M. De Francesco [Wed, 13 Apr 2022 22:55:31 +0000 (23:55 +0100)]
media: staging: media: atomisp: Use kmap_local_page() in hmm_store()

The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. The same is true for kmap_atomic().

In file pci/hmm/hmm.c, function hmm_store() test if we are in atomic
context and, if so, it calls kmap_atomic(), if not, it calls kmap().

First of all, in_atomic() shouldn't be used in drivers. This macro
cannot always detect atomic context; in particular, it cannot know
about held spinlocks in non-preemptible kernels.

Notwithstanding what it is said above, this code doesn't need to care
whether or not it is executing in atomic context. It can simply use
kmap_local_page() / kunmap_local() that can instead do the mapping /
unmapping regardless of the context.

With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Therefore, hmm_store()() is a function where the use
of kmap_local_page() in place of both kmap() and kmap_atomic() is
correctly suited.

Convert the calls of kmap() / kunmap() and kmap_atomic() /
kunmap_atomic() to kmap_local_page() / kunmap_local() and drop the
unnecessary tests which test if the code is in atomic context.

Link: https://lore.kernel.org/linux-media/20220413225531.9425-1-fmdefrancesco@gmail.com
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: atomisp: Use kmap_local_page() in hmm_set()
Fabio M. De Francesco [Wed, 13 Apr 2022 21:22:10 +0000 (22:22 +0100)]
media: staging: media: atomisp: Use kmap_local_page() in hmm_set()

The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. In file pci/hmm/hmm.c, function hmm_set() calls
kmap() / kunmap() where kmap_local_page() can instead do the mapping.

With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Therefore, hmm_set()() is a function where the use
of kmap_local_page() in place of kmap() is correctly suited.

Convert the calls of kmap() / kunmap() to kmap_local_page() /
kunmap_local().

Link: https://lore.kernel.org/linux-media/20220413212210.18494-1-fmdefrancesco@gmail.com
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: media: atomisp: Convert kmap() to kmap_local_page()
Fabio M. De Francesco [Fri, 8 Apr 2022 22:31:29 +0000 (23:31 +0100)]
media: staging: media: atomisp: Convert kmap() to kmap_local_page()

The use of kmap() is being deprecated in favor of kmap_local_page() where
it is feasible. With kmap_local_page(), the mapping is per thread, CPU
local and not globally visible.

load_and_flush_by_kmap() is a function where the use of kmap_local_page()
in place of kmap() is correctly suited.

Convert load_and_flush_by_kmap() from kmap() to kmap_local_page().

Link: https://lore.kernel.org/linux-media/20220408223129.3844-1-fmdefrancesco@gmail.com
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: staging: atomisp: rework reading the id and revision values
Tom Rix [Sat, 26 Mar 2022 19:18:53 +0000 (19:18 +0000)]
media: staging: atomisp: rework reading the id and revision values

Clang static analysis reports this representative issue
atomisp-ov2722.c:920:3: warning: 3rd function call
  argument is an uninitialized value
  dev_err(&client->dev, "sensor_id_high = 0x%x\n", high);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

high and low are only set when ov2722_read_reg() is successful.
Reporting the high value when there is an error is not
meaningful.  The later read for low is not checked.  high
and low are or-ed together and checked against a non zero
value.

Remove the unneeded error reporting for high.  Initialize
high and low to 0 and use the id check to determine if
the reads were successful

The later read for revision is not checked.  If it
fails the old high value will be used and the revision
will be misreported.

Since the revision is only reported and not checked or
stored it is not necessary to return if the read with
successful.  This makes the ret variable unnecessary
so remove it.

Link: https://lore.kernel.org/linux-media/20220326191853.2914552-1-trix@redhat.com
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: Add a notes.txt file
Hans de Goede [Wed, 15 Jun 2022 20:50:37 +0000 (21:50 +0100)]
media: atomisp: Add a notes.txt file

Add a files documenting what I've learned about the driver while
working on various cleanups.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-41-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>
2 years agomedia: atomisp: remove force argument from __destroy_[stream[s]|pipe[s]]()
Hans de Goede [Wed, 15 Jun 2022 20:50:36 +0000 (21:50 +0100)]
media: atomisp: remove force argument from __destroy_[stream[s]|pipe[s]]()

The force argument to the __destroy_pipe[s]() and __destroy_stream[s]()
functions is always true. Remove the argument and remove the code necessary
to handle the false case.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-40-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>
2 years agomedia: atomisp: use atomisp_destroy_pipes_stream_force() in more places
Hans de Goede [Wed, 15 Jun 2022 20:50:35 +0000 (21:50 +0100)]
media: atomisp: use atomisp_destroy_pipes_stream_force() in more places

Use atomisp_destroy_pipes_stream_force() in 4 more places,
instead of open coding it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-39-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>
2 years agomedia: atomisp: use atomisp_css_update_stream() in more places
Hans de Goede [Wed, 15 Jun 2022 20:50:34 +0000 (21:50 +0100)]
media: atomisp: use atomisp_css_update_stream() in more places

Use atomisp_css_update_stream() in 2 more places,
instead of open coding it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-38-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>
2 years agomedia: atomisp: use atomisp_create_pipes_stream() in more places
Hans de Goede [Wed, 15 Jun 2022 20:50:33 +0000 (21:50 +0100)]
media: atomisp: use atomisp_create_pipes_stream() in more places

Use atomisp_create_pipes_stream() in 2 more places,
instead of open coding it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-37-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>
2 years agomedia: atomisp: add error logging to atomisp_destroy_pipes_stream_force()
Hans de Goede [Wed, 15 Jun 2022 20:50:32 +0000 (21:50 +0100)]
media: atomisp: add error logging to atomisp_destroy_pipes_stream_force()

__destroy_streams() and __destroy_pipes() may return an error.
Log a warning when either of them fails.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-36-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>
2 years agomedia: atomisp: add error checking to atomisp_create_pipes_stream()
Hans de Goede [Wed, 15 Jun 2022 20:50:31 +0000 (21:50 +0100)]
media: atomisp: add error checking to atomisp_create_pipes_stream()

The functions called by atomisp_create_pipes_stream() can fail,
add error checking for them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-35-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>
2 years agomedia: atomisp: fix __get_frame_info() error handling
Hans de Goede [Wed, 15 Jun 2022 20:50:30 +0000 (21:50 +0100)]
media: atomisp: fix __get_frame_info() error handling

On ia_css_pipe_get_info() errors, destroy both the streams as well
as the pipes which were created.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-34-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>
2 years agomedia: atomisp: remove hmm_page_object
Hans de Goede [Wed, 15 Jun 2022 20:50:29 +0000 (21:50 +0100)]
media: atomisp: remove hmm_page_object

hmm_page_object only stores a struct page pointer, so we can just use
the hmm_bo.pages page pointer array everywhere.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-33-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>
2 years agomedia: atomisp: drop HMM_BO_SHARE type
Hans de Goede [Wed, 15 Jun 2022 20:50:28 +0000 (21:50 +0100)]
media: atomisp: drop HMM_BO_SHARE type

HMM_BO_SHARE is not supported by the hmm_bo code at all, drop it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-32-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>
2 years agomedia: atomisp: drop highmem var/arg from the hmm code
Hans de Goede [Wed, 15 Jun 2022 20:50:27 +0000 (21:50 +0100)]
media: atomisp: drop highmem var/arg from the hmm code

highmem is always false, drop it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-31-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>
2 years agomedia: atomisp: Simplify hmm_alloc() calls
Hans de Goede [Wed, 15 Jun 2022 20:50:26 +0000 (21:50 +0100)]
media: atomisp: Simplify hmm_alloc() calls

Make hmm_alloc() only take size as a parameter and remove other parameters.
since all callers always pass the same flags.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-30-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>
2 years agomedia: atomisp: add hmm_create_from_userdata() helper
Hans de Goede [Wed, 15 Jun 2022 20:50:25 +0000 (21:50 +0100)]
media: atomisp: add hmm_create_from_userdata() helper

Most hmm_alloc() callers want BO_PRIVATE type memory.

Add a hmm_create_from_userdata() helper for other cases so that
the hmm_alloc() calls for all the callers who don't want this
can be simplied.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-29-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>
2 years agomedia: atomisp: remove unused hmm address translation functions
Hans de Goede [Wed, 15 Jun 2022 20:50:24 +0000 (21:50 +0100)]
media: atomisp: remove unused hmm address translation functions

hmm_isp_vaddr_to_host_vaddr() and hmm_host_vaddr_to_hrt_vaddr()
are unused, remove them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-28-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>
2 years agomedia: atomisp: drop unused ATOMISP_MAP_FLAG_* flags
Hans de Goede [Wed, 15 Jun 2022 20:50:23 +0000 (21:50 +0100)]
media: atomisp: drop unused ATOMISP_MAP_FLAG_* flags

Drop the ATOMISP_MAP_FLAG_CACHED flag, it is never set anywhere;
also drop the matching "cached" parameter to hmm[_bo]_alloc which
value was derived form the never set flag.

Drop the ATOMISP_MAP_FLAG_NOFLUSH, it is not used anywhere.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-27-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>
2 years agomedia: atomisp: drop ATOMISP_MAP_FLAG_CLEARED
Hans de Goede [Wed, 15 Jun 2022 20:50:22 +0000 (21:50 +0100)]
media: atomisp: drop ATOMISP_MAP_FLAG_CLEARED

This flag is only used by one hmm_alloc() caller, drop it and make
the caller call hmm_set(ptr, 0, size) itself to do the clearing.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-26-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>
2 years agomedia: atomisp: drop unused ATOMISP_ACC_FW_LOAD_* defines
Hans de Goede [Wed, 15 Jun 2022 20:50:21 +0000 (21:50 +0100)]
media: atomisp: drop unused ATOMISP_ACC_FW_LOAD_* defines

Drop the ATOMISP_ACC_FW_LOAD_* defines, these are no longer used anywhere.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-25-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>
2 years agomedia: atomisp: remove atomisp_is_acc_enabled()
Hans de Goede [Wed, 15 Jun 2022 20:50:20 +0000 (21:50 +0100)]
media: atomisp: remove atomisp_is_acc_enabled()

atomisp_is_acc_enabled() always returns false now, remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-24-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>
2 years agomedia: atomisp: remove no longer used atomisp_css_acc_done() function
Hans de Goede [Wed, 15 Jun 2022 20:50:19 +0000 (21:50 +0100)]
media: atomisp: remove no longer used atomisp_css_acc_done() function

atomisp_css_acc_done() is no longer used anywhere, remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-23-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>
2 years agomedia: atomisp: asc.acc.pipeline is always NULL
Hans de Goede [Wed, 15 Jun 2022 20:50:18 +0000 (21:50 +0100)]
media: atomisp: asc.acc.pipeline is always NULL

With the removal of the ACC ioctls and atomisp_acc.c asc.acc.pipeline
never gets set, so it is always NULL.

Remove asc.acc.pipeline and drop checks for it being NULL / !NULL.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-22-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>
2 years agomedia: atomisp: remove unused atomisp_*css_* functions
Hans de Goede [Wed, 15 Jun 2022 20:50:17 +0000 (21:50 +0100)]
media: atomisp: remove unused atomisp_*css_* functions

With the removal of the ACC ioctls and atomisp_acc.c a whole bunch
of atomisp_*css_* functions is no longer used, remove them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-21-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>
2 years agomedia: atomisp: remove atomisp_acc.c
Hans de Goede [Wed, 15 Jun 2022 20:50:16 +0000 (21:50 +0100)]
media: atomisp: remove atomisp_acc.c

With the ACC ioctls removed sd->acc.fw is always empty turning
the atomisp_acc.c code into no-ops, remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-20-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>
2 years agomedia: atomisp: remove private acceleration ioctls
Hans de Goede [Wed, 15 Jun 2022 20:50:15 +0000 (21:50 +0100)]
media: atomisp: remove private acceleration ioctls

These ioctls allow userspace to load custom programs into the ISP, which:

a) Seems dangerous
b) Cannot be used by opensource userspace since there is no FOSS code to
   create such programs
b) These seem to be unused even by the Android closed source camera code
   (they don't show up in a strace of the camera app)

So removing these seems be a good idea. Another reason to remove these is
that atomisp_acc_map() is the only user of the userptr functionality in
hmm_alloc(), so it gets in the way of further cleanups / simplification
of the hmm code.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-19-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>
2 years agomedia: atomisp: remove bogus comment above hmm_bo_allocated() prototype
Hans de Goede [Wed, 15 Jun 2022 20:50:14 +0000 (21:50 +0100)]
media: atomisp: remove bogus comment above hmm_bo_allocated() prototype

The comment documenting hmm_bo_allocated() was copied (and not modified)
from the comment documenting hmm_bo_alloc(), so there are 2 copies
of the hmm_bo_alloc() documentation.

Remove the copy of the comment above the hmm_bo_allocated() prototype.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-18-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>
2 years agomedia: atomisp: removed unused hmm_bo_get_page_info() function
Hans de Goede [Wed, 15 Jun 2022 20:50:13 +0000 (21:50 +0100)]
media: atomisp: removed unused hmm_bo_get_page_info() function

hmm_bo_get_page_info() is not used anywhere, remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-17-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>
2 years agomedia: atomisp: drop hmm_page_type
Hans de Goede [Wed, 15 Jun 2022 20:50:12 +0000 (21:50 +0100)]
media: atomisp: drop hmm_page_type

Since the hmm-pool code has been removed this now always gets set
to HMM_PAGE_TYPE_GENERAL, so just remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-16-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>
2 years agomedia: atomisp: remove unused attribute argument from ia_css_frame_map()
Hans de Goede [Wed, 15 Jun 2022 20:50:11 +0000 (21:50 +0100)]
media: atomisp: remove unused attribute argument from ia_css_frame_map()

ia_css_frame_map() has only one caller which passes a hardcoded 0
for the attribute argument, drop it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-15-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>
2 years agomedia: atomisp: remove pool related kernel cmdline options
Hans de Goede [Wed, 15 Jun 2022 20:50:10 +0000 (21:50 +0100)]
media: atomisp: remove pool related kernel cmdline options

Since we have removed the hmm pools these are completely meaningless now.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-14-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>
2 years agomedia: atomisp: remove hmm_mem_stats
Hans de Goede [Wed, 15 Jun 2022 20:50:09 +0000 (21:50 +0100)]
media: atomisp: remove hmm_mem_stats

Without pool support the (optional) debug logging done by these is
not really meaningful, drop it all.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-13-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>
2 years agomedia: atomisp: remove hmm pool code
Hans de Goede [Wed, 15 Jun 2022 20:50:08 +0000 (21:50 +0100)]
media: atomisp: remove hmm pool code

Since we never register any pools, this is all dead code,
remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-12-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>
2 years agomedia: atomisp: remove dynamic and reserved pool code
Hans de Goede [Wed, 15 Jun 2022 20:50:07 +0000 (21:50 +0100)]
media: atomisp: remove dynamic and reserved pool code

There are no callers of this code atm; and looking at the atomisp
memory-management code if anything we want to make it simpler and
not re-introduce use of these pools, so remove the pool code.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-11-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>
2 years agomedia: atomisp: remove hmm_pool_[un]register()
Hans de Goede [Wed, 15 Jun 2022 20:50:06 +0000 (21:50 +0100)]
media: atomisp: remove hmm_pool_[un]register()

These are no-ops, so lets remove them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-10-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atomisp: drop ATOMISP_MAP_FLAG_CONTIGUOUS
Hans de Goede [Wed, 15 Jun 2022 20:50:05 +0000 (21:50 +0100)]
media: atomisp: drop ATOMISP_MAP_FLAG_CONTIGUOUS

Drop the ATOMISP_MAP_FLAG_CONTIGUOUS hmm_alloc flag. After the contiguous
flag removal done in previous patches in this series it is never set.

And hmm_alloc already did a WARN_ON on the flag and otherwise ignored it,
proving that contiguous support was already never used.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-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>
2 years agomedia: atomisp: drop contiguous flag from struct ia_css_frame
Hans de Goede [Wed, 15 Jun 2022 20:50:04 +0000 (21:50 +0100)]
media: atomisp: drop contiguous flag from struct ia_css_frame

Drop the contiguous flag from struct ia_css_frame, it is always false /
not used.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-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>
2 years agomedia: atomisp: drop IA_CSS_FRAME_FORMAT_MIPI support from ia_css_frame_init_planes()
Hans de Goede [Wed, 15 Jun 2022 20:50:03 +0000 (21:50 +0100)]
media: atomisp: drop IA_CSS_FRAME_FORMAT_MIPI support from ia_css_frame_init_planes()

Nothing ever sets the format to IA_CSS_FRAME_FORMAT_MIPI and
frame_init_mipi_plane() is the only code-path which ever sets
frame->contiguous to true.

Drop A_CSS_FRAME_FORMAT_MIPI support from ia_css_frame_init_planes()
as part of the removal of contiguous alloc support from the frame code.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-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>
2 years agomedia: atomisp: drop contiguous argument from frame_create()
Hans de Goede [Wed, 15 Jun 2022 20:50:02 +0000 (21:50 +0100)]
media: atomisp: drop contiguous argument from frame_create()

Drop the contiguous argument from frame_create()
all callers always passes false.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-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>
2 years agomedia: atomisp: drop contiguous argument from frame_allocate_with_data()
Hans de Goede [Wed, 15 Jun 2022 20:50:01 +0000 (21:50 +0100)]
media: atomisp: drop contiguous argument from frame_allocate_with_data()

Drop the contiguous argument from frame_allocate_with_data()
its only caller always passes false.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-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>
2 years agomedia: atomisp: drop contiguous argument from ia_css_frame_allocate_with_buffer_size()
Hans de Goede [Wed, 15 Jun 2022 20:50:00 +0000 (21:50 +0100)]
media: atomisp: drop contiguous argument from ia_css_frame_allocate_with_buffer_size()

Drop the contiguous argument from ia_css_frame_allocate_with_buffer_size()
its only caller always passes false.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-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>
2 years agomedia: atomisp: remove unused ia_css_frame_allocate_contiguous*() functions
Hans de Goede [Wed, 15 Jun 2022 20:49:59 +0000 (21:49 +0100)]
media: atomisp: remove unused ia_css_frame_allocate_contiguous*() functions

ia_css_frame_allocate_contiguous() and
ia_css_frame_allocate_contiguous_from_info() are not used anywhere,
remove them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-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>
2 years agomedia: atomisp: remove the unused RAW_BUF_STRIDE macro
Hans de Goede [Wed, 15 Jun 2022 20:49:58 +0000 (21:49 +0100)]
media: atomisp: remove the unused RAW_BUF_STRIDE macro

I noticed that the RAW_BUF_STRIDE macro is using the removed
SH_CSS_BINARY_ID_POST_ISP define, which should be a problem except that
the RAW_BUF_STRIDE macro itself is not used at all, remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-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>
2 years agomedia: On Semi AR0521 sensor driver
Krzysztof Hałasa [Tue, 1 Mar 2022 08:41:38 +0000 (08:41 +0000)]
media: On Semi AR0521 sensor driver

The driver has been extensively tested in an i.MX6-based system.
AR0521 is a 5.7 mm x 4.3 mm, 5 MPix RGGB MIPI/HiSPi BSI CMOS sensor
from On Semiconductor.

Signed-off-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>
2 years agomedia: dt-bindings: Add bindings for On Semi AR0521 camera sensor
Krzysztof Hałasa [Tue, 1 Mar 2022 08:38:04 +0000 (08:38 +0000)]
media: dt-bindings: Add bindings for On Semi AR0521 camera sensor

This patch documents DT bindings for the AR0521 camera sensor driver.

[Sakari Ailus: Reworked subject and commit message a little]

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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>
2 years agomedia: ov5640: Move format mux config in format
Jacopo Mondi [Fri, 13 May 2022 14:14:16 +0000 (15:14 +0100)]
media: ov5640: Move format mux config in format

The image format produced by the sensor is controlled by two registers,
whose values computation is open coded in ov5640_set_framefmt().

As we have a list of formats already, move the OV5640_REG_FORMAT_CONTROL00
and OV5640_REG_ISP_FORMAT_MUX_CTRL register values to the static list
of formats instead of open coding it.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5640: Split DVP and CSI-2 formats
Jacopo Mondi [Fri, 13 May 2022 14:14:15 +0000 (15:14 +0100)]
media: ov5640: Split DVP and CSI-2 formats

The format enumeration list is shared between CSI-2 and DVP modes.
This lead to the enumeration of unsupported format variants in both
modes.

Separate the list of DVP and CSI-2 formats and create helpers to access
the correct one.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5640: Adjust format to bpp in s_fmt
Jacopo Mondi [Fri, 13 May 2022 14:14:14 +0000 (15:14 +0100)]
media: ov5640: Adjust format to bpp in s_fmt

The ov5640 driver supports different sizes for different mbus_codes.
In particular:

- 8bpp modes: high resolution sizes (>= 1280x720)
- 16bpp modes: all sizes
- 24bpp modes: low resolutions sizes (< 1280x720)

Adjust the image sizes according to the above constraints.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5640: Restrict sizes to mbus code
Jacopo Mondi [Fri, 13 May 2022 14:14:13 +0000 (15:14 +0100)]
media: ov5640: Restrict sizes to mbus code

The ov5640 driver supports different sizes for different mbus_codes.
In particular:

- 8bpp modes: high resolution sizes (>= 1280x720)
- 16bpp modes: all sizes
- 24bpp modes: low resolutions sizes (< 1280x720)

Restrict the frame sizes enumerations to the above constraints.

While at it, make sure the fse->mbus_code parameter is valid, and return
-EINVAL if it's not.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5640: Add BGR888 format
Jacopo Mondi [Fri, 13 May 2022 14:14:12 +0000 (15:14 +0100)]
media: ov5640: Add BGR888 format

Add support for BGR888 image format.

No existing media bus codes describe exactly the way data is transferred
on the CSI-2 bus. This is not a new issue, the CSI-2 YUV422 8-bit format
is described by MEDIA_BUS_FMT_UYVY8_1X16 which is an arbitrary
convention and not an exact match. Use the MEDIA_BUS_FMT_BGR888_1X24 to
follow the same convention, based on the order in which bits are
transmitted over the CSI-2 bus when producing images in RGB24 format.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5640: Add RGB565_1X16 format
Jacopo Mondi [Fri, 13 May 2022 14:14:11 +0000 (15:14 +0100)]
media: ov5640: Add RGB565_1X16 format

The driver already supports the 2X8_[LE|BE] variants of RGB565
formats.

As for CSI-2 the 2X8 variants do not apply, add RGB565_1X16 variant
with little-endian ordering of components as required by the CSI-2
specifications.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5640: Register device properties
Jacopo Mondi [Fri, 13 May 2022 14:14:10 +0000 (15:14 +0100)]
media: ov5640: Register device properties

Parse the device properties and register the rotation and orientation
V4L2 controls using v4l2_ctrl_new_fwnode_properties().

Remove the open-coded parsing of the rotation property and assume the
DTS is correct is providing either <0> or <180> as possible rotations.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>