Commit graph

916285 commits

Author SHA1 Message Date
Mauro Carvalho Chehab
4f744a573d media: atomisp: make sh_css_sp_init_pipeline() ISP version independent
This function call has two parameters that are used only with
ISP2401, enclosed on some ugly ifdefs. Make the function independent,
passing NULL values for ISP2400.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
977e77c0b5 media: atomisp: make sh_css_struct.h independent of ISP version
Use the same struct for both ISP2400 and ISP2401.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
ffa123612a media: atomisp: sh_css_defs.h: get rid of build time dependencies
There are several #ifdefs checking for ISP version there. Some
of them are just two different ways to represent the same contants,
while 3 parameters are actually different, depending on the ISP
version.

Change the header in a way that it will be compatible with both
versions, and change dependent code to keep running, removing
ifdefs there only when possible.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
483f5215a2 media: atomisp: atomisp_compat_ioctl32.c: be independent of ISP version
There are two ioctls that are only available with ISP2401. Yet,
at the compat level, we don't really need to take care, as
the native ioctl handler will already return an error code if
the ioctl doesn't exist.

So, let's just remove the ifdefs here.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
7ef17aa55f media: atomisp: atomisp_compat_css20.c: detect ISP at runtime
Remove ifdefs that check ISP version from the code, switching
to specific ISP-dependent code at runtime.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
78e2888ccb media: atomisp: atomisp_csi2.c: remove useless ifdefs
The ifdefs there are meaningless. Just remove them for good.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
02c392332c media: atomisp: atomisp_subdev.c check ISP version on runtime
Remove ISP-version-dependent ifdefs.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
a19b190e32 media: atomisp: atomisp_v4l2.c: set wdt timers according with ISP version
Add a runtime check to use the proper wdt timer init at runtime,
depending on the chipset revision.

For now, we can't get rid of the remaining version checks, as
the rest of the code is not prepared yet to detect the ISP
version on runtime.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
9ace178dee media: atomisp: atomisp_ioctl.c: get rid of a ISP2400/ISP2401 dependency
Replace #ifdef occurrences there with runtime checks.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
643405b0ff media: atomisp: pci/atomisp2/*.h remove #ifdef ISP2401
Those ifs can easily be removed without breaking the code.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
268ff5bf6b media: atomisp: atomisp_dfs_tables.h: don't depend on ISP version
There's a dependency on this header for the ISP model. While
this sounds really weird (as just one resolution needs it),
as we don't know what's the right value, let's just keep it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
ea419fdae5 media: atomisp: atomisp_cmd.c test ISP version in runtime
The logic there has lots of ifdef dependencies if the hardware
is either ISP2400 or ISP2041.

Replace them by runtime checks.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:16 +02:00
Mauro Carvalho Chehab
e1ac35b39a media: atomisp: add a way for the driver to know the chipset version
The atomisp supports two different chipsets: ISP2400 and ISP2401.
Right now, this is controlled by ugly #defines inside the driver.

Add a global bolean to identify the type of hardware. While this
is hacky, it would be a quick way to start removing the ugly
ifdefs.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:15 +02:00
Mauro Carvalho Chehab
9a0d7fb5ec media: atomisp: simplify math_support.h
There are some uneeded defines there. Simplify it, and make
it independent of defines.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:15 +02:00
Mauro Carvalho Chehab
02330fb010 media: atomisp: remove some dead code
There are several parts of atomisp that are meant to be
built on different environments, tested using ifdefs.

Remove some of them, as this code should build only on
Linux.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:15 +02:00
Mauro Carvalho Chehab
eaa399eb54 media: atomisp: do lots of other coding style cleanups
Use some auto-reformat tools to make the atomisp style
a little better. There are still lots of weird things there,
but this will hopefully reduce the number of pure coding
style patches submitted upstream.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:15 +02:00
Mauro Carvalho Chehab
bdfe0beb95 media: atomisp: fix several coding style issues
Use checkpatch.pl --fix-inplace --strict to solve several
coding style issues, manually reviewing the produced code and
fixing some troubles caused by checkpatch.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:15 +02:00
Mauro Carvalho Chehab
4636a85cff media: atomisp: fix several typos
Running checkpatch.pl codespell logic found several typos at atomisp
driver.

Fix them using --fix-inline.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:15 +02:00
Mauro Carvalho Chehab
fd3218f513 media: atomisp: select IOSF_MBI dependency
This driver needs IOSF_MBI in order to talk with some PM
registers. Select it at compile time.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:15 +02:00
Mauro Carvalho Chehab
aa31f65140 media: atomisp: allow building the driver again
The atomisp driver builds again. So, remove depends on BROKEN.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:14 +02:00
Mauro Carvalho Chehab
e7b955f8e0 media: atomisp: fix a broken compat32 code
There's a typo at the compat32 code, with forgot to get the
pointer address, causing the driver to not build.

Not sure why this didn't produce an error back when the
driver got removed.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:14 +02:00
Mauro Carvalho Chehab
c1b70ae094 media: atomisp: use new ida API
The old ida API got replaced by a new one, with avoids
locking issues. As the old API was removed, start using the
new one, as defined by changeset b03f8e43c9 ("ida: Remove old API").

Fixes: b03f8e43c9 ("ida: Remove old API")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:14 +02:00
Mauro Carvalho Chehab
8d564cd28c media: atomisp: use cpu_latency_qos_*() instead of pm_qos_update*()
Those functions got renamed. Update them on atomisp driver.

Fixes: 67b06ba018 ("PM: QoS: Drop PM_QOS_CPU_DMA_LATENCY and rename related functions")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:14 +02:00
Mauro Carvalho Chehab
a9d7bbcc6b media: atomisp: Fix support for time 64 API
The time 64 API patchset changed the ts stamp to u64.

Update this driver accordingly.

Fixes: 15a40b27be ("media: videobuf: use u64 for the timestamp internally")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:14 +02:00
Mauro Carvalho Chehab
e58eeb5a73 media: atomisp: replace VFL_TYPE_GRABBER by VFL_TYPE_VIDEO
This type was renamed in the past by a more meaningul
name. Change it on atomisp too.

Fixes: 238e4a5baa ("media: rename VFL_TYPE_GRABBER to _VIDEO")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:14 +02:00
Mauro Carvalho Chehab
1aeb9583d3 media: atomisp: totalram_pages is now a function
Fix the usage of totalram_pages, as this is now a function.

Fixes: ca79b0c211 ("mm: convert totalram_pages and totalhigh_pages variables to atomic")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:14 +02:00
Mauro Carvalho Chehab
60e5c18945 media: atomisp: fix usage of access_ok() kAPI
This macro had its first parameter lost. Remove it.

While on it, fix the alignments where this macro is used.

Fixes: 96d4f267e4 ("Remove 'type' argument from access_ok() function")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:14 +02:00
Mauro Carvalho Chehab
99da46648a MAINTAINERS: adjust atomisp maintainership
From now on, I'll be maintaining the atomisp driver, and
Sakari will be reviewing it.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:32:14 +02:00
Mauro Carvalho Chehab
ad85094b29 Revert "media: staging: atomisp: Remove driver"
There are some interest on having this driver back, and I
can probably dedicate some time to address its issue. So,
let's ressurect it.

For now, the driver causes a recursive error and doesn't
build, so, make it depend on BROKEN.

This reverts commit 51b8dc5163.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-20 12:26:12 +02:00
Jacopo Mondi
ad3a44cbd1 media: i2c: imx219: Parse and register properties
Parse device properties and register controls for them using the newly
introduced helpers.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:37:16 +02:00
Jacopo Mondi
74c3ddd988 media: i2c: ov13858: Parse and register properties
Parse device properties and register controls for them using the newly
introduced helpers.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:36:58 +02:00
Jacopo Mondi
eba08021e1 media: i2c: ov5670: Parse and register properties
Parse device properties and register controls for them using the newly
introduced helpers.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:36:37 +02:00
Jacopo Mondi
e0a360630d media: v4l2-ctrls: Add helper to register properties
Add an helper function to v4l2-ctrls to register controls associated
with a device property.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:36:20 +02:00
Jacopo Mondi
e0837a6c08 media: v4l2-ctrls: Sort includes alphabetically
Before adding a new include directive, sort the existing ones in
alphabetical order.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:35:53 +02:00
Jacopo Mondi
ae6ff16cf7 media: include: v4l2-ctrl: Sort forward declarations
Before adding a new forward declaration to the v4l2-ctrls.h header file,
sort the existing ones alphabetically.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:35:33 +02:00
Jacopo Mondi
344897ef1d media: v4l2-fwnode: Add helper to parse device properties
Add an helper function to parse common device properties in the same
way as v4l2_fwnode_endpoint_parse() parses common endpoint properties.

Parse the 'rotation' and 'orientation' properties from the firmware
interface.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:34:56 +02:00
Jacopo Mondi
926645d43f media: v4l2-ctrls: Add camera orientation and rotation
Add support for the newly defined V4L2_CID_CAMERA_ORIENTATION
and V4L2_CID_CAMERA_SENSOR_ROTATION read-only controls used to report
the camera device mounting position and orientation respectively.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:34:21 +02:00
Jacopo Mondi
9926c22487 media: v4l2-ctrl: Document V4L2_CID_CAMERA_SENSOR_ROTATION
Add documentation for the V4L2_CID_CAMERA_SENSOR_ROTATION camera
control. The newly added read-only control reports the rotation
correction to be applied to images before displaying them to the user.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:33:48 +02:00
Jacopo Mondi
9397a83f40 media: v4l2-ctrl: Document V4L2_CID_CAMERA_ORIENTATION
Add documentation for the V4L2_CID_CAMERA_ORIENTATION camera
control. The newly added read-only control reports the camera device
orientation relative to the usage orientation of the system the camera
is installed on.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:33:26 +02:00
Jacopo Mondi
915bd31ce9 media: dt-bindings: video-interface: Replace 'rotation' description
Replace the 'rotation' property description by providing a definition
relative to the camera sensor pixel array coordinate system and the
captured scene.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:32:56 +02:00
Jacopo Mondi
cabc918e5b media: dt-bindings: video-interfaces: Document 'orientation' property
Add the 'orientation' device property, used to specify the device mounting
position. The property is particularly meaningful for mobile devices
with a well defined usage orientation.

Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:31:43 +02:00
Steve Longerbeam
c4e0536603 media: imx: TODO: Remove media link creation todos
Remove the TODO items regarding media link creation, these issues are
resolved by moving media link creation to individual entity bound
callbacks and the implementation of the get_fwnode_pad operation.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 15:30:16 +02:00
Steve Longerbeam
50da3f36e6 media: imx: silence a couple debug messages
Convert to dev_dbg the "subdev bound" and IPU-internal media-link
creation messages.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.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+huawei@kernel.org>
2020-05-18 15:29:57 +02:00
Steve Longerbeam
f0c1210f8a media: imx: Create missing links from CSI-2 receiver
The entities external to the i.MX6 IPU and i.MX7 now create the links
to their fwnode-endpoint connected entities in their notifier bound
callbacks. Which means imx_media_create_of_links() and
imx_media_create_csi_of_links() are no longer needed and are removed.

However there is still one case in which imx-media needs to create
fwnode-endpoint based links at probe completion. The v4l2-async framework
does not allow multiple subdevice notifiers to contain a duplicate
subdevice in their asd_list. Only the first subdev notifier that discovers
and adds that one subdevice to its asd_list will receive a bound callback
for it. Other subdevices that also have firmware endpoint connections to
this duplicate subdevice will not have it in their asd_list, and thus will
never receive a bound callback for it. In the case of imx-media, the one
duplicate subdevice in question is the i.MX6 MIPI CSI-2 receiver.

Until there is a solution to that problem, rewrite imx_media_create_links()
to add the missing links from the CSI-2 receiver to the CSIs and CSI muxes.
The function is renamed imx_media_create_csi2_links().

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.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+huawei@kernel.org>
2020-05-18 14:37:56 +02:00
Steve Longerbeam
f02eac790d media: imx: csi: Lookup upstream endpoint with imx_media_get_pad_fwnode
Fix the 1:1 port-id:pad-index assumption for the upstream subdevice, by
searching the upstream subdevice's endpoints for one that maps to the
pad's index. This is carried out by a new reverse mapping function
imx_media_get_pad_fwnode().

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 14:30:44 +02:00
Steve Longerbeam
86e02d0787 media: imx5/6/7: csi: Mark a bound video mux as a CSI mux
For i.MX5/6, if the bound subdev is a video mux, it must be one of the
CSI muxes, and for i.MX7, the bound subdev must always be a CSI mux.

So if the bound subdev is a video mux, mark it as a CSI mux with a new
group id IMX_MEDIA_GRP_ID_CSI_MUX.

In the process use the new group id in csi_get_upstream_endpoint(), and
do some cleanup in that function for better readability.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 14:29:35 +02:00
Steve Longerbeam
fe7aee5d35 media: imx7: csi: Remove imx7_csi_get_upstream_endpoint()
The function imx7_csi_get_upstream_endpoint() is not necessary for
imx7. First, the imx7 CSI only receives from the CSI mux, so much of
the code in there is pointless. Second, it is only used to determine
whether the CSI mux has selected the CSI-2 input or the parallel input.
This can be accomplished much more simply by getting the function type
of selected input entity to the CSI mux.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 14:23:11 +02:00
Steve Longerbeam
2c586f1891 media: imx: csi: Create media links in bound notifier
Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the CSI sink pad.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 14:22:41 +02:00
Steve Longerbeam
94b99296f3 media: imx7: csi: Create media links in bound notifier
Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the CSI sink pad.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 14:21:56 +02:00
Steve Longerbeam
6e996653e7 media: imx7: mipi csis: Create media links in bound notifier
Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the mipi csi-2 receiver sink pad.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-18 14:21:35 +02:00