aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/media (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-07-19media: ti-vpe: cal: Use 'unsigned int' type instead of 'unsigned'Laurent Pinchart1-1/+1
Specifying 'int' explicitly is generally preferred in the kernel for unsigned int types. Fix the only wrong occurrence. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Remove unneeded phy->sensor NULL checkLaurent Pinchart1-3/+0
The phy->sensor NULL check in cal_camerarx_get_external_rate() is not needed, as the V4L2 video devices are only registered when the sensor is bound. Remove it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Don't store external rate in cal_camerarxLaurent Pinchart1-14/+21
The external pixel rate is retrieved when starting the camerarx and only used then. There's no need to store it in the cal_camerarx structure, it can be returned by cal_camerarx_get_external_info() and explicitly passed to cal_camerarx_config(). While at it, rename cal_camerarx_get_external_info() to cal_camerarx_get_external_rate() to better reflect the function's purpose. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Refactor camerarx start and stopLaurent Pinchart1-76/+94
Refactor the camerarx start and stop procedure to group all the corresponding operations in two functions, cal_camerarx_start() and cal_camerarx_stop() instead of splitting them in multiple steps called from the vb2 stream start and stop functions. This reduces the coupling between the camerarx and the contexts, and better models the camerarx hardware. The cal_camerarx_start() is a reworked version of cal_camerarx_init() with the description of the start procedure updated to match the AM65x, DRA7[124567]x and DRA80xM TRMs. The cal_camerarx_wait_ready() function is inlined in cal_camerarx_start() to better describe the start procedure. No functional change is included in the camerarx start and stop procedures themselves, but the interleaving of the start steps with the context configuration has been changed in cal_start_streaming(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Reorder camerarx functions to prepare refactoringLaurent Pinchart1-214/+214
To prepare for the camerarx refactoring, reorder functions without any functional change to ease review of the refactoring itself. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Inline cal_camerarx_max_lanes() in its only callerLaurent Pinchart1-8/+2
The cal_camerarx_max_lanes() function is a one-liner that has a single caller. It doesn't improve readability. Inline it in its caller. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Allocate cal_ctx active_fmt array dynamicallyLaurent Pinchart1-1/+7
To avoid making the cal_ctx structure layoug depend on the size of the cal_formats array, allocate the active_fmt array dynamically. This prepares for splitting the driver in multiple files. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Init formats in cal_ctx_v4l2_register()Laurent Pinchart1-44/+39
To prepare for splitting the V4L2 API support to a separate file, call cal_ctx_v4l2_init_formats() from cal_ctx_v4l2_register(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Register a media deviceLaurent Pinchart1-22/+49
Enable the media controller API by registering a media device and initializing the media entities corresponding to the video devices. The context initialization is slightly refactored as a result. The media graph will be built in a subsequent change. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Store struct device in cal_devLaurent Pinchart1-28/+27
The cal_dev structure stores the platform_device pointer, but most accesses to that field need the device pointer. Store the struct device pointer directly to simplify the code, and use to_platform_device() in the two locations that need the platform device. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Print revision and hwinfo in a more readable formatLaurent Pinchart1-7/+22
Print the hardware revision in the X.Y.R format, which is more readable that the 32-bit hex value. For the hardware info register, only print its value if it doesn't contain what we expect. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Read hardware revision earlier during probeLaurent Pinchart1-13/+13
Read the hardware revision and info right after allocating resources, as there's no need to delay doing so until all initialization is complete. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Split media initialization and cleanup to functionsLaurent Pinchart1-26/+90
Create four functions to handle initialization, cleanup, registration and unregistration of the V4L2 (and soon media controller) objects: - init() is meant to be called early at probe time to initialize the objects, before they get used from within the kernel - cleanup() is the counterpart of init, and is meant to be called at the end of the remove sequence to free all objects - register() is meant to be called at the end of the probe sequence, to register the userspace-facing devices - unregister() is the counterpart of register, and is meant to be called at the beginning for the remove sequence, to disallow access from userspace Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Replace number of ports numerical value by macroLaurent Pinchart1-1/+1
Use the CAL_NUM_CSI2_PORTS macro instead of the hardcoded numerical value 2 to iterate over the CSI-2 ports. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Remove isvcirqset() and isportirqset() macrosLaurent Pinchart1-7/+2
The isvcirqset() isn't used. The isportirqset() doesn't increase readability. Inline the latter and simply drop the former. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Move CAL_NUM_CSI2_PORTS from cal_regs.h to cal.cLaurent Pinchart2-5/+4
The CAL_NUM_CSI2_PORTS macro isn't a register definition. Move it to cal.c, and fix indentation of the other macros while at it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Decouple context and phy cleanup at remove timeLaurent Pinchart1-9/+15
The driver happens the use the same number of CAMERARX and context, but coupling their cleanup at remove time is wrong. To prepare for the introduction of additional contexts, decouple the two. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Operate on phy instances in cal_quickdump_regs()Laurent Pinchart1-13/+11
The cal_quickdump_regs() dumps registers for the two CAMERARX instances. Retrieve those instances from the cal_dev directly instead of going through the contexts, and simplify the code by using a loop. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Replace context with phy in async notifier entriesLaurent Pinchart1-12/+12
The async notifier is meant to bind to subdevs connected to the CSI-2 ports. Those ports are modelled by the CAMERARX phy instances. To prepare for additional decoupling of contexts and phys, make the notifier operate on phys. We still initialize and register the context V4L2 support in the async notifier complete operation as that's our signal that the userspace API is ready to be exposed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Move async notifiers from contexts to cal_devLaurent Pinchart1-46/+71
There's no need to create one async notifier per CAL context. Merge them all in a single notifier, stored in cal_dev. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Allow multiple contexts per subdev notifierLaurent Pinchart1-1/+16
The subdev notifier handling assumes a 1:1 mapping between CAL contexts and notifiers. To prepare for merging the multiple notifiers into a single one, retrieve the CAL context from the async subdev structure instead of from the notifier. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Move all sensor-related init to .bound() notifierLaurent Pinchart1-64/+68
The initialization of the context based on the connected sensor is split between the async notifier .bound() and .complete() operations. Move it all to a separate function and call it from .bound() operation to prepare for the move of the notifiers from the contexts to the cal_dev. Only V4L2 registration is kept in the .complete() operation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Use ARRAY_SIZE to replace numerical valueLaurent Pinchart1-4/+4
Use ARRAY_SIZE(cal->ctx) to iterate over the cal->ctx array instead of using the numerical value from the CAL_NUM_CONTEXT macro (or, worse, hardcoding the value 2). This will allow reworking contexts with less changes in the code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Move DT parsing to CAMERARXLaurent Pinchart1-74/+111
The DT port nodes corresponding to the CSI-2 inputs belong to the CAMERARX instances. Move parsing of the DT properties to a new cal_camerarx_parse_dt() function, called by cal_camerarx_create(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Add cal_camerarx_destroy() to cleanup CAMERARXLaurent Pinchart1-6/+30
The cal_camerarx_create() function allocates resources with devm_*, and thus doesn't need any manual cleanup. Those won't hold true for long, as we will need to store resources that have no devm_* allocation variant in cal_camerarx. Furthermore, devm_kzalloc() is the wrong memory allocation API for structures that can be accessed from userspace, as device nodes can be kept open across device removal. Add a cal_camerarx_destroy() function to destroy a CAMERARX instance explicitly, and switch to kzalloc() for memory allocation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Unregister video device before cleanupLaurent Pinchart1-1/+1
In cal_remove(), unregister the video devices as the first operation, before cleaning up the V4L2 objects, to avoid use-after-free. This isn't a complete solution yet, as video nodes can be kept open across unregistration. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Add context V4L2 cleanup and unregister functionsLaurent Pinchart1-3/+13
Create cal_ctx_v4l2_unregister() and cal_ctx_v4l2_cleanup() functions to unregister and cleanup the V4L2-related objects from the context, and call them in cal_remove() and in the error path of cal_probe(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Split video device initialization and registrationLaurent Pinchart1-28/+42
There's no need to delay most of the video device initialization until the sensor subdevs are bound. Split the initialization and registration, and perform the initialization when creating the context. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Move v4l2_device from cal_ctx to cal_devLaurent Pinchart1-22/+22
The v4l2_device structure is meant to represent the whole device. In the CAL case, this corresponds to the CAL, the CAMERARX instances and the connected sensors. There should thus be a single v4l2_device instance. Replace the per-context instance with a global instance in the cal_dev structure. Don't set the v4l2_device name manually as v4l2_device_register() sets it to a value that is suitable for the driver. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Decouple control handler from v4l2_deviceLaurent Pinchart1-15/+19
To prepare for decoupling the v4l2_device from the cal_ctx, don't set the control handler in the v4l2_device and expect the video node to use it automatically, but set the video node control handler directly. This requires adding the sensor subdev controls to the control handler manually, as that operation was performed on the v4l2_device by v4l2_device_register_subdev(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Fix usage of v4l2_fwnode_endpoint_parse()Laurent Pinchart1-5/+4
Letting the v4l2_fwnode_endpoint_parse() function determine the bus type automatically is deprecated. Set the bus type to DPHY manually as the TI CAL only supports DPHY. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Use of_graph_get_endpoint_by_regs() to parse OFLaurent Pinchart1-107/+7
Replace the manual of_get_next_port() and of_get_next_endpoint() implementations and the corresponding logic in the caller with a call to of_graph_get_endpoint_by_regs(). This greatly simplifies OF parsing. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Hardcode virtual channel to 0Laurent Pinchart1-7/+1
Using the endpoint reg value to pass the CSI-2 source virtual channel ID in DT is a hack, isn't documented in the DT bindings, and isn't used in neither upstream DT nor TI official overlays. Hardcode the virtual channel to 0 to simplify reworking the code, proper virtual channel support will be implemented later. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Rename cal_create_instance() to cal_ctx_create()Laurent Pinchart1-2/+2
The cal_create_instance() function creates a CAL context. Rename it to cal_ctx_create() to make its purpose more explicit. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Add comments to cal_probe() to delimitate sectionsLaurent Pinchart1-6/+5
The cal_probe() function is a bit long, add comments to delimitate sections in order to improve readability. The platform_set_drvdata() call is moved to a more logical place as a result. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Inline cal_get_camerarx_regmap() in callerLaurent Pinchart1-43/+32
The cal_get_camerarx_regmap() function is called in a single place. Inline it in its caller, as it results in a clear code flow. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Use syscon_regmap_lookup_by_phandle_args()Laurent Pinchart1-11/+8
Use the syscon_regmap_lookup_by_phandle_args() function to replace manual lookup of the syscon regmap offset. This simplifies the cal_camerarx_init_regmap() implementation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Split CAMERARX syscon regmap retrieval to a functionLaurent Pinchart1-31/+42
Simplify the cal_probe() function by splitting the CAMERARX syscon regmap retrieval to a separate function. A few local variables are renamed in the process to shorten them (syscon_camerrx_*) or to make them more accurate (parent isn't the parent OF node but the CAL device's own OF node). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Drop struct cal_dev v4l2_dev fieldLaurent Pinchart1-5/+0
The v4l2_dev field of the cal_dev structure is initialized but never used. Drop it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Use a loop to create CAMERARX and context instancesLaurent Pinchart1-15/+6
Replace a manually unrolled loop with an explicit for loop to increase readability when creating the CAMERARX and context instances. The explicit NULL initialization of cal->phy[] and cal->ctx[] is removed, as the cal structure is zeroed when allocated. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Use ctx_info() instead of v4l2_info()Laurent Pinchart1-2/+2
Use the context-specific print macro to replace the last usage of the v4l2_* print macros. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Get struct device without going through v4l2_deviceLaurent Pinchart1-1/+1
Instead of retrieving the struct device for the platform device from the v4l2_device, get it from the platform device directly. This prepares for cleanups related to v4l2_device handling. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Use correct device name for bus_infoLaurent Pinchart1-1/+1
The v4l2_capability bus_info field, filled by the VIDIOC_QUERYCAP ioctl handler, specifies the location of the device in the system. For platform devices, V4L2 specifies that the value must be "platform:" followed by the device name. Fix the cal_querycap() function to set the right value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Rename cal_ctx.csi2_port to cal_ctx.indexLaurent Pinchart1-25/+25
The csi2_port field of the cal_ctx structure holds the context index, and is independent from the CSI-2 port (even if it currently has the same numerical value). Rename it to index to avoid the ambiguity. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Reorganize remaining code in sectionsLaurent Pinchart1-158/+182
Increase readability by reorganizing the remaining code in sections. No functional change is included. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Create consistent naming for context functionsLaurent Pinchart1-11/+16
Rename all functions related to contexts with a cal_ctx_ prefix to increase readability. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Inline cal_data_get_num_csi2_phy() in its callerLaurent Pinchart1-7/+2
The cal_data_get_num_csi2_phy() function simply returns cal->data->num_csi2_phy, and is not consistently used across the driver, as most accesses to cal->data->num_csi2_phy are open-coded. We could fix those open-coded accesses to use cal_data_get_num_csi2_phy(), but that wouldn't bring much in terms of readability, so inline cal_data_get_num_csi2_phy() in its only caller instead, and drop the function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Group CAMERARX-related functions togetherLaurent Pinchart1-167/+166
Group the CAMERARX functions together to make the overall driver structure easier to navigate. This only moves functions around, no functional change is included. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Create consistent naming for CAMERARX functionsLaurent Pinchart1-124/+119
Rename all functions related to CAMERARX with a cal_camerarx_ prefix, and pass them a cal_camerarx pointer. This performs most of the decoupling of the CAMERARX from the context. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-19media: ti-vpe: cal: Store sensor-related data in cal_camerarxLaurent Pinchart1-29/+30
The sensor is connected to the CAMERARX. Store its pointer, as well as the sensor pixel rate and the endpoint, in the cal_camerarx. This prepares for decoupling the cal_camerarx and cal_ctx. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>