Support for Tegra video capture from external sensor
Subsystems (8)
Sowjanya Komatineni
maintainerv8 cover Support for Tegra video capture from external sensor
This series adds support for video capture from external camera sensor to Tegra video driver.
Jetson TX1 has camera expansion connector and supports custom camera module designed as per TX1 design specification.
This series also enables camera capture support for Jetson Nano which has Raspberry PI camera header.
This series is tested with IMX274 and IMX219 camera sensors.
This series include,
Tegra video driver updates
- TPG Vs Non-TPG based on Kconfig
- Support for external sensor video capture based on device graph from DT
- Support for selection ioctl operations
- Tegra MIPI CSI pads calibration
- CSI T-CLK and T-HS settle time computation based on clock rates
- dt-binding doc update
Host1x driver updates
- Keep MIPI clock enabled till calibration is done
Delta between patch versions:
[v8]: Includes below minor changes
- Fixed missing of_node_put and updated error message to be more informative in tegra_csi_channels_alloc() and tegra_vi_channels_alloc()
Patch-0006 has compilation dependency on
https://patchwork.kernel.org/patch/11659521/
[v7]: Includes minor feedback from v6
- Patch-0009 has minor update
Note:
Patch-0006 has compilation dependency on
https://patchwork.kernel.org/patch/11659521/
[v6]: Includes below changes based on v5 feedback
- Patches are based on latest linux-next.
- separated stream enable and disable implementations into separate functions for tegra_channel_set_stream() and tegra_csi_s_stream().
- changed dev_err to dev_warn on MIPI calibration failure after sensor streaming as its not critical error.
Note:
Patch-0006 has compilation dependency on
https://patchwork.kernel.org/patch/11659521/
[v5]: Includes below minor change based on v4 feedback
Patch-0012: renames APIs to use calibration instead of calibrate.
Note:
Patch-0010 has compilation dependency on
https://patchwork.kernel.org/patch/11659521/
[v4]: Includes below fix based on v3 feedback
- Patches are based on latest linux-next.
- With split of tegra_mipi_calibrate() and tegra_mipi_wait(), mipi clock is not left enabled till calibration done. This series adds a patch to fix this by keeping clock enabled till calibration is done.
Note:
Patch-0010 has compilation dependency on
https://patchwork.kernel.org/patch/11659521/
[v3]: Includes v2 feedback
- Uses separate helper function for retrieving remote csi subdevice and source subdevice.
- Added check for presence of subdevice ops set/get_selection
- dropped vb2_queue_release from driver and using vb2_video_unregister_device instead of video_unregister_device.
- video device register should happen in the last after all video device related setup is done in the driver. This is being addressed in below RFC patch. Once proper implementation of this is available will update Tegra video driver to use split APIs and do all setup prior to device register. Added this as TODO in the driver.
https://www.spinics.net/lists/linux-media/msg172761.html
Note:
Patch-0012 has compilation dependency on
https://patchwork.kernel.org/patch/11659521/
[v2]: Includes below changes based on v1 feedback
- dt-binding document and the driver update for device graph to use separate ports for sink endpoint and source endpoint for csi.
- Use data-lanes endpoint property for csi.
- Update tegra_mipi_request() to take device node pointer argument rather than adding extra API.
- Remove checking for clk pointer before clk_disable.
Sowjanya Komatineni (10):
media: tegra-video: Fix channel format alignment
media: tegra-video: Enable TPG based on kernel config
media: tegra-video: Update format lookup to offset based
dt-bindings: tegra: Update VI and CSI bindings with port info
media: tegra-video: Separate CSI stream enable and disable
implementations
media: tegra-video: Add support for external sensor capture
media: tegra-video: Add support for selection ioctl ops
gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
media: tegra-video: Add CSI MIPI pads calibration
media: tegra-video: Compute settle times based on the clock rate
.../display/tegra/nvidia,tegra20-host1x.txt | 92 ++- drivers/gpu/drm/tegra/dsi.c | 4 +- drivers/gpu/host1x/mipi.c | 19 +- drivers/staging/media/tegra-video/Kconfig | 7 + drivers/staging/media/tegra-video/TODO | 6 - drivers/staging/media/tegra-video/csi.c | 314 +++++++- drivers/staging/media/tegra-video/csi.h | 8 + drivers/staging/media/tegra-video/tegra210.c | 25 +- drivers/staging/media/tegra-video/vi.c | 841 +++++++++++++++++++-- drivers/staging/media/tegra-video/vi.h | 25 +- drivers/staging/media/tegra-video/video.c | 23 +- include/linux/host1x.h | 5 +- 12 files changed, 1252 insertions(+), 117 deletions(-)
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerPATCH v8 1/10 media: tegra-video: Fix channel format alignment
Pixel format width is mistakenly aligned to surface align bytes and altering width to aligned value may force sensor mode change other than the requested one and also cause mismatch in width programmed between sensor and vi which can lead to capture errors.
This patch removes width alignment and clamps width as per Tegra minimum and maximum limits.
--- drivers/staging/media/tegra-video/vi.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/staging/media/tegra-video/vi.c +3 -13
@@ -359,25 +359,15 @@ static void tegra_channel_fmt_align(struct tegra_vi_channel *chan, struct v4l2_pix_format *pix, unsigned int bpp) { -unsigned int align; -unsigned int min_width; -unsigned int max_width; -unsigned int width;unsigned int min_bpl;unsigned int max_bpl;unsigned int bpl;/* -* The transfer alignment requirements are expressed in bytes. Compute -* minimum and maximum values, clamp the requested width and convert -* it back to pixels. Use bytesperline to adjust the width. +* The transfer alignment requirements are expressed in bytes. +* Clamp the requested width and height to the limits. */ - align =lcm (SURFACE_ALIGN_BYTES , bpp); - min_width =roundup (TEGRA_MIN_WIDTH , align); - max_width =rounddown (TEGRA_MAX_WIDTH , align); - width =roundup (pix->width * bpp, align); - - pix->width =clamp (width, min_width, max_width) / bpp; + pix->width =clamp (pix->width,TEGRA_MIN_WIDTH ,TEGRA_MAX_WIDTH ); pix->height =clamp (pix->height,TEGRA_MIN_HEIGHT ,TEGRA_MAX_HEIGHT );/* Clamp the requested bytes per line value. If the maximum bytes per
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerPATCH v8 2/10 media: tegra-video: Enable TPG based on kernel config
In reply to Sowjanya KomatineniTegra internal TPG mode is only for Tegra vi and csi testing without a real sensor and driver should default support real sensor.
So, This patch adds CONFIG_VIDEO_TEGRA_TPG and enables Tegra internal TPG mode only when this config is selected.
--- drivers/staging/media/tegra-video/Kconfig | 6 +++++ drivers/staging/media/tegra-video/csi.c | 38 +++++++++++++++++++++++----- drivers/staging/media/tegra-video/tegra210.c | 6 +++++ drivers/staging/media/tegra-video/vi.c | 13 +++++++--- drivers/staging/media/tegra-video/video.c | 23 +++++++++-------- 5 files changed, 65 insertions(+), 21 deletions(-)
drivers/staging/media/tegra-video/Kconfig +6 -0
@@ -10,3 +10,9 @@ config VIDEO_TEGRA To compile this driver as a module, choose M here: the module will be called tegra-video. + +config VIDEO_TEGRA_TPG + bool "NVIDIA Tegra VI driver TPG mode" + depends on VIDEO_TEGRA + help + Say yes here to enable Tegra internal TPG mode
drivers/staging/media/tegra-video/csi.c +31 -7
@@ -62,6 +62,9 @@ static int csi_enum_bus_code(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { +if (!IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) +return -ENOIOCTLCMD ; +if (code->index >=ARRAY_SIZE (tegra_csi_tpg_fmts))return -EINVAL ;
@@ -76,6 +79,9 @@ static int csi_get_format(struct v4l2_subdev *subdev, {struct tegra_csi_channel *csi_chan =to_csi_chan (subdev); +if (!IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) +return -ENOIOCTLCMD ; + fmt->format = csi_chan->format;return 0 ;
@@ -121,6 +127,9 @@ static int csi_enum_framesizes(struct v4l2_subdev *subdev, {unsigned int i; +if (!IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) +return -ENOIOCTLCMD ; +if (fse->index >=ARRAY_SIZE (tegra_csi_tpg_sizes))return -EINVAL ;
@@ -148,6 +157,9 @@ static int csi_enum_frameintervals(struct v4l2_subdev *subdev,const struct tpg_framerate *frmrate = csi->soc->tpg_frmrate_table;int index; +if (!IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) +return -ENOIOCTLCMD ; +/* one framerate per format and resolution */ if (fie->index >0 )return -EINVAL ;
@@ -172,6 +184,9 @@ static int csi_set_format(struct v4l2_subdev *subdev,const struct v4l2_frmsize_discrete *sizes;unsigned int i; +if (!IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) +return -ENOIOCTLCMD ; + sizes = v4l2_find_nearest_size(tegra_csi_tpg_sizes, ARRAY_SIZE(tegra_csi_tpg_sizes), width, height,
@@ -208,6 +223,9 @@ static int tegra_csi_g_frame_interval(struct v4l2_subdev *subdev, {struct tegra_csi_channel *csi_chan =to_csi_chan (subdev); +if (!IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) +return -ENOIOCTLCMD ; + vfi->interval.numerator =1 ; vfi->interval.denominator = csi_chan->framerate;
@@ -311,8 +329,12 @@ static int tegra_csi_channel_init(struct tegra_csi_channel *chan) subdev = &chan->subdev;v4l2_subdev_init (subdev, &tegra_csi_ops); subdev->dev = csi->dev; -snprintf (subdev->name,V4L2_SUBDEV_NAME_SIZE ,"%s-%d" ,"tpg" , - chan->csi_port_num); +if (IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) +snprintf (subdev->name,V4L2_SUBDEV_NAME_SIZE ,"%s-%d" ,"tpg" , + chan->csi_port_num); +else +snprintf (subdev->name,V4L2_SUBDEV_NAME_SIZE ,"%s" , +kbasename (chan->of_node->full_name));v4l2_set_subdevdata (subdev, chan); subdev->fwnode =of_fwnode_handle (chan->of_node);
@@ -405,11 +427,13 @@ static int tegra_csi_init(struct host1x_client *client)INIT_LIST_HEAD (&csi->csi_chans); - ret =tegra_csi_tpg_channels_alloc (csi); -if (ret <0 ) { -dev_err (csi->dev, -"failed to allocate tpg channels: %d\n" , ret); - goto cleanup; +if (IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) { + ret =tegra_csi_tpg_channels_alloc (csi); +if (ret <0 ) { +dev_err (csi->dev, +"failed to allocate tpg channels: %d\n" , ret); + goto cleanup; + } } ret =tegra_csi_channels_init (csi);
drivers/staging/media/tegra-video/tegra210.c +6 -0
@@ -631,7 +631,11 @@ const struct tegra_vi_soc tegra210_vi_soc = { .ops = &tegra210_vi_ops, .hw_revision = 3, .vi_max_channels = 6, +#if IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG ) .vi_max_clk_hz = 499200000, +#else + .vi_max_clk_hz = 998400000, +#endif };/* Tegra210 CSI PHY registers accessors */
@@ -957,7 +961,9 @@ static const char * const tegra210_csi_cil_clks[] = {"cilab" ,"cilcd" ,"cile" , +#if IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG) "csi_tpg", +#endif };/* Tegra210 CSI operations */
drivers/staging/media/tegra-video/vi.c +9 -4
@@ -565,6 +565,7 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) {int ret; +#if IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )/* add test pattern control handler to v4l2 device */ v4l2_ctrl_new_std_menu_items(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_TEST_PATTERN,
@@ -576,6 +577,7 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan)v4l2_ctrl_handler_free (&chan->ctrl_handler); return chan->ctrl_handler.error; } +#endif /* setup the controls */ ret =v4l2_ctrl_handler_setup (&chan->ctrl_handler);
@@ -918,10 +920,13 @@ static int tegra_vi_init(struct host1x_client *client)INIT_LIST_HEAD (&vi->vi_chans); - ret =tegra_vi_tpg_channels_alloc (vi); -if (ret <0 ) { -dev_err (vi->dev,"failed to allocate tpg channels: %d\n" , ret); - goto free_chans; +if (IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) { + ret =tegra_vi_tpg_channels_alloc (vi); +if (ret <0 ) { +dev_err (vi->dev, +"failed to allocate tpg channels: %d\n" , ret); + goto free_chans; + } } ret =tegra_vi_channels_init (vi);
drivers/staging/media/tegra-video/video.c +13 -10
@@ -60,15 +60,17 @@ static int host1x_video_probe(struct host1x_device *dev)if (ret <0 ) goto unregister_v4l2; -/* -* Both vi and csi channels are available now. -* Register v4l2 nodes and create media links for TPG. -*/ - ret =tegra_v4l2_nodes_setup_tpg (vid); -if (ret <0 ) { -dev_err (&dev->dev, -"failed to setup tpg graph: %d\n" , ret); - goto device_exit; +if (IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) { +/* +* Both vi and csi channels are available now. +* Register v4l2 nodes and create media links for TPG. +*/ + ret =tegra_v4l2_nodes_setup_tpg (vid); +if (ret <0 ) { +dev_err (&dev->dev, +"failed to setup tpg graph: %d\n" , ret); + goto device_exit; + } }return 0 ;
@@ -91,7 +93,8 @@ static int host1x_video_remove(struct host1x_device *dev) {struct tegra_video_device *vid =dev_get_drvdata (&dev->dev); -tegra_v4l2_nodes_cleanup_tpg (vid); +if (IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) +tegra_v4l2_nodes_cleanup_tpg (vid);host1x_device_exit (dev);
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerPATCH v8 3/10 media: tegra-video: Update format lookup to offset based
In reply to Sowjanya KomatineniTegra VI supported video formats are more for non TPG and there can be multiple pixel formats for the same media bus format.
This patch updates the helper function for format lookup based on mbus code from pre-defined Tegra supported format list to look from the specified list index offset.
Offset based look up is used with sensor device graph (non TPG) where format enumeration can list all supported formats for the specific sensor mbus codes.
--- drivers/staging/media/tegra-video/vi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/staging/media/tegra-video/vi.c +6 -4
@@ -53,11 +53,12 @@ to_tegra_channel_buffer(struct vb2_v4l2_buffer *vb) }static int tegra_get_format_idx_by_code (struct tegra_vi *vi, -unsigned int code) +unsigned int code, +unsigned int offset) {unsigned int i; -for (i =0 ; i < vi->soc->nformats; ++i) { +for (i = offset; i < vi->soc->nformats; ++i) {if (vi->soc->video_formats[i].code == code)return i; }
@@ -598,11 +599,12 @@ static void vi_tpg_fmts_bitmap_init(struct tegra_vi_channel *chan)bitmap_zero (chan->tpg_fmts_bitmap,MAX_FORMAT_NUM ); index =tegra_get_format_idx_by_code (chan->vi, -MEDIA_BUS_FMT_SRGGB10_1X10 ); +MEDIA_BUS_FMT_SRGGB10_1X10 ,0 );bitmap_set (chan->tpg_fmts_bitmap, index,1 ); index =tegra_get_format_idx_by_code (chan->vi, -MEDIA_BUS_FMT_RGB888_1X32_PADHI ); +MEDIA_BUS_FMT_RGB888_1X32_PADHI , +0 );bitmap_set (chan->tpg_fmts_bitmap, index,1 ); }
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerPATCH v8 4/10 dt-bindings: tegra: Update VI and CSI bindings with port info
In reply to Sowjanya KomatineniUpdate VI and CSI bindings to add port and endpoint nodes as per media video-interfaces DT binding document.
--- .../display/tegra/nvidia,tegra20-host1x.txt | 92 +++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt +90 -2
@@ -51,8 +51,16 @@ of the following host1x client modules: - vi - Tegra210: - power-domains: Must include venc powergate node as vi is in VE partition. - - Tegra210 has CSI part of VI sharing same host interface and register space. - So, VI device node should have CSI child node. + + ports (optional node) + vi can have optional ports node and max 6 ports are supported. Each port + should have single 'endpoint' child node. All port nodes are grouped under + ports node. Please refer to the bindings defined in + Documentation/devicetree/bindings/media/video-interfaces.txt + + csi (required node) + Tegra210 has CSI part of VI sharing same host interface and register space. + So, VI device node should have CSI child node. - csi: mipi csi interface to vi
@@ -65,6 +73,46 @@ of the following host1x client modules: - power-domains: Must include sor powergate node as csicil is in SOR partition. + channel (optional nodes) + Maximum 6 channels are supported with each csi brick as either x4 or x2 + based on hw connectivity to sensor. + + Required properties: + - reg: csi port number. Valid port numbers are 0 through 5. + - nvidia,mipi-calibrate: Should contain a phandle and a specifier + specifying which pads are used by this CSI port and need to be + calibrated. See also ../display/tegra/nvidia,tegra114-mipi.txt. + + Each channel node must contain 2 port nodes which can be grouped + under 'ports' node and each port should have a single child 'endpoint' + node. + + ports node + Please refer to the bindings defined in + Documentation/devicetree/bindings/media/video-interfaces.txt + + ports node must contain below 2 port nodes. + port@0 with single child 'endpoint' node always a sink. + port@1 with single child 'endpoint' node always a source. + + port@0 (required node) + Required properties: + - reg: 0 + + endpoint (required node) + Required properties: + - data-lanes: an array of data lane from 1 to 4. Valid array + lengths are 1/2/4. + - remote-endpoint: phandle to sensor 'endpoint' node. + + port@1 (required node) + Required properties: + - reg: 1 + + endpoint (required node) + Required properties: + - remote-endpoint: phandle to vi port 'endpoint' node. + - epp: encoder pre-processor Required properties:
@@ -340,6 +388,18 @@ Example: ranges = <0x0 0x0 0x54080000 0x2000>; + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + imx219_vi_in0: endpoint { + remote-endpoint = <&imx219_csi_out0>; + }; + }; + }; + csi@838 { compatible = "nvidia,tegra210-csi"; reg = <0x838 0x1300>;
@@ -362,6 +422,34 @@ Example: <&tegra_car TEGRA210_CLK_CSI_TPG>; clock-names = "csi", "cilab", "cilcd", "cile", "csi_tpg"; power-domains = <&pd_sor>; + + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + nvidia,mipi-calibrate = <&mipi 0x001>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + imx219_csi_in0: endpoint { + data-lanes = <1 2>; + remote-endpoint = <&imx219_out0>; + }; + }; + + port@1 { + reg = <1>; + imx219_csi_out0: endpoint { + remote-endpoint = <&imx219_vi_in0>; + }; + }; + }; + }; }; };
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerPATCH v8 5/10 media: tegra-video: Separate CSI stream enable and disable implementations
In reply to Sowjanya KomatineniThis patch separates implementation of CSI stream enable and disable into separate functions for readability.
--- drivers/staging/media/tegra-video/csi.c | 51 ++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-)
drivers/staging/media/tegra-video/csi.c +35 -16
@@ -232,34 +232,53 @@ static int tegra_csi_g_frame_interval(struct v4l2_subdev *subdev,return 0 ; } -static int tegra_csi_s_stream (struct v4l2_subdev *subdev,int enable) +static int tegra_csi_enable_stream (struct v4l2_subdev *subdev) {struct tegra_vi_channel *chan =v4l2_get_subdev_hostdata (subdev);struct tegra_csi_channel *csi_chan =to_csi_chan (subdev);struct tegra_csi *csi = csi_chan->csi; -int ret =0 ; +int ret; + + ret =pm_runtime_get_sync (csi->dev); +if (ret <0 ) { +dev_err (csi->dev,"failed to get runtime PM: %d\n" , ret); +pm_runtime_put_noidle (csi->dev); +return ret; + } csi_chan->pg_mode = chan->pg_mode; -if (enable) { - ret =pm_runtime_get_sync (csi->dev); -if (ret <0 ) { -dev_err (csi->dev, -"failed to get runtime PM: %d\n" , ret); -pm_runtime_put_noidle (csi->dev); -return ret; - } + ret = csi->ops->csi_start_streaming (csi_chan); +if (ret <0 ) + goto rpm_put; - ret = csi->ops->csi_start_streaming (csi_chan); -if (ret <0 ) - goto rpm_put; +return 0 ; -return 0 ; - } +rpm_put: +pm_runtime_put (csi->dev); +return ret; +} + +static int tegra_csi_disable_stream (struct v4l2_subdev *subdev) +{ +struct tegra_csi_channel *csi_chan =to_csi_chan (subdev); +struct tegra_csi *csi = csi_chan->csi; csi->ops->csi_stop_streaming (csi_chan); -rpm_put:pm_runtime_put (csi->dev); + +return 0 ; +} + +static int tegra_csi_s_stream (struct v4l2_subdev *subdev,int enable) +{ +int ret; + +if (enable) + ret =tegra_csi_enable_stream (subdev); +else + ret =tegra_csi_disable_stream (subdev); +return ret; }
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerPATCH v8 6/10 media: tegra-video: Add support for external sensor capture
In reply to Sowjanya KomatineniThis patch adds support to capture from the external sensor based on device graph in the device tree.
Driver walks through the device graph to create media links between the entities and registers and unregisters video devices when the corresponding sub-devices are bound and unbound.
Channel formats are enumerated based on available formats from the sensor and the corresponding matched formats from the Tegra supported video formats list.
Each Tegra CSI instance can be configured as 4-lane or 2-lane based on supported lane configuration from the sensor through the device tree.
Currently this driver supports V4L2 video node centric only.
--- drivers/staging/media/tegra-video/Kconfig | 1 + drivers/staging/media/tegra-video/TODO | 4 - drivers/staging/media/tegra-video/csi.c | 139 +++++- drivers/staging/media/tegra-video/csi.h | 1 + drivers/staging/media/tegra-video/tegra210.c | 2 +- drivers/staging/media/tegra-video/vi.c | 692 +++++++++++++++++++++++++-- drivers/staging/media/tegra-video/vi.h | 25 +- 7 files changed, 800 insertions(+), 64 deletions(-)
drivers/staging/media/tegra-video/Kconfig +1 -0
@@ -5,6 +5,7 @@ config VIDEO_TEGRA depends on VIDEO_V4L2 select MEDIA_CONTROLLER select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE help Choose this option if you have an NVIDIA Tegra SoC.
drivers/staging/media/tegra-video/TODO +0 -4
@@ -1,8 +1,4 @@ TODO list -* Currently driver supports Tegra build-in TPG only with direct media links - from CSI to VI. Add kernel config CONFIG_VIDEO_TEGRA_TPG and update the - driver to do TPG Vs Sensor media links based on CONFIG_VIDEO_TEGRA_TPG. -* Add real camera sensor capture support. * Add Tegra CSI MIPI pads calibration. * Add MIPI clock Settle time computation based on the data rate. * Add support for Ganged mode.
drivers/staging/media/tegra-video/csi.c +120 -19
188 lines not on this page · raw message
drivers/staging/media/tegra-video/csi.h +1 -0
@@ -7,6 +7,7 @@#define __TEGRA_CSI_H__#include <media/media-entity.h> +#include <media/v4l2-async.h> #include <media/v4l2-subdev.h> /*
drivers/staging/media/tegra-video/tegra210.c +1 -1
@@ -230,7 +230,7 @@ static void tegra_channel_capture_error_recover(struct tegra_vi_channel *chan)tegra_channel_capture_setup (chan);/* recover CSI block */ - subdev =tegra_channel_get_remote_subdev (chan); + subdev =tegra_channel_get_remote_csi_subdev (chan);tegra_csi_error_recover (subdev); }
drivers/staging/media/tegra-video/vi.c +653 -39
856 lines not on this page · raw message
drivers/staging/media/tegra-video/vi.h +24 -1
@@ -14,6 +14,7 @@#include <linux/wait.h> #include <media/media-entity.h> +#include <media/v4l2-async.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-dev.h>
@@ -93,6 +94,19 @@ struct tegra_vi { };/** +* struct tegra_vi_graph_entity - Entity in the video graph +* +* @asd: subdev asynchronous registration information +* @entity: media entity from the corresponding V4L2 subdev +* @subdev: V4L2 subdev +*/ +struct tegra_vi_graph_entity { +struct v4l2_async_subdev asd; +struct media_entity *entity; +struct v4l2_subdev *subdev; +}; + +/** * struct tegra_vi_channel - Tegra video channel * * @list: list head for this entry
@@ -138,10 +152,13 @@ struct tegra_vi {* @done_lock: protects the capture done queue list * * @portno: VI channel port number +* @of_node: device node of VI channel * * @ctrl_handler: V4L2 control handler of this video channel +* @fmts_bitmap: a bitmap for supported formats matching v4l2 subdev formats * @tpg_fmts_bitmap: a bitmap for supported TPG formats * @pg_mode: test pattern generator mode (disabled/direct/patch) +* @notifier: V4L2 asynchronous subdevs notifier */ struct tegra_vi_channel {struct list_head list;
@@ -174,10 +191,14 @@ struct tegra_vi_channel {spinlock_t done_lock;unsigned char portno; +struct device_node *of_node;struct v4l2_ctrl_handler ctrl_handler; +DECLARE_BITMAP (fmts_bitmap,MAX_FORMAT_NUM );DECLARE_BITMAP (tpg_fmts_bitmap,MAX_FORMAT_NUM );enum tegra_vi_pg_mode pg_mode; + +struct v4l2_async_notifier notifier; };/**
@@ -249,7 +270,9 @@ extern const struct tegra_vi_soc tegra210_vi_soc;#endif struct v4l2_subdev * -tegra_channel_get_remote_subdev (struct tegra_vi_channel *chan); +tegra_channel_get_remote_csi_subdev (struct tegra_vi_channel *chan); +struct v4l2_subdev * +tegra_channel_get_remote_source_subdev (struct tegra_vi_channel *chan);int tegra_channel_set_stream (struct tegra_vi_channel *chan,bool on);void tegra_channel_release_buffers (struct tegra_vi_channel *chan,enum vb2_buffer_state state);
Signature · 1 line
2.7.4
Re: [PATCH v8 06/10] media: tegra-video: Add support for external sensor capture
03.08.2020 18:42, Sowjanya Komatineni пишет:
Quoted 18 lines
This patch adds support to capture from the external sensor based on device graph in the device tree.
Driver walks through the device graph to create media links between the entities and registers and unregisters video devices when the corresponding sub-devices are bound and unbound.
Channel formats are enumerated based on available formats from the sensor and the corresponding matched formats from the Tegra supported video formats list.
Each Tegra CSI instance can be configured as 4-lane or 2-lane based on supported lane configuration from the sensor through the device tree.
Currently this driver supports V4L2 video node centric only.
Signed-off-by Sowjanya Komatineni <[email protected]>
Quoted 9 lines
--- drivers/staging/media/tegra-video/Kconfig | 1 + drivers/staging/media/tegra-video/TODO | 4 - drivers/staging/media/tegra-video/csi.c | 139 +++++- drivers/staging/media/tegra-video/csi.h | 1 + drivers/staging/media/tegra-video/tegra210.c | 2 +- drivers/staging/media/tegra-video/vi.c | 692 +++++++++++++++++++++++++-- drivers/staging/media/tegra-video/vi.h | 25 +- 7 files changed, 800 insertions(+), 64 deletions(-)
This and the rest of the patches look sane to me, thanks.
Sowjanya Komatineni
maintainerPATCH v8 7/10 media: tegra-video: Add support for selection ioctl ops
In reply to Sowjanya KomatineniThis patch adds selection v4l2 ioctl operations to allow configuring a selection rectangle in the sensor through the Tegra video device node.
Some sensor drivers supporting crop uses try_crop rectangle from v4l2_subdev_pad_config during try format for computing binning.
So with selection ops support, this patch also updates try format to use try crop rectangle either from subdev frame size enumeration or from subdev crop boundary.
--- drivers/staging/media/tegra-video/vi.c | 106 +++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)
drivers/staging/media/tegra-video/vi.c +106 -0
@@ -474,6 +474,13 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan,struct v4l2_subdev *subdev;struct v4l2_subdev_format fmt;struct v4l2_subdev_pad_config *pad_cfg; +struct v4l2_subdev_frame_size_enum fse = { + .which =V4L2_SUBDEV_FORMAT_TRY , + }; +struct v4l2_subdev_selection sdsel = { + .which =V4L2_SUBDEV_FORMAT_ACTIVE , + .target =V4L2_SEL_TGT_CROP_BOUNDS , + };int ret; subdev =tegra_channel_get_remote_source_subdev (chan);
@@ -499,6 +506,24 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, fmt.which =V4L2_SUBDEV_FORMAT_TRY ; fmt.pad =0 ;v4l2_fill_mbus_format (&fmt.format, pix, fmtinfo->code); + +/* +* Attempt to obtain the format size from subdev. +* If not available, try to get crop boundary from subdev. +*/ + fse.code = fmtinfo->code; + ret =v4l2_subdev_call (subdev, pad, enum_frame_size, pad_cfg, &fse); +if (ret) { + ret =v4l2_subdev_call (subdev, pad, get_selection,NULL , &sdsel); +if (ret) +return -EINVAL ; + pad_cfg->try_crop.width = sdsel.r.width; + pad_cfg->try_crop.height = sdsel.r.height; + }else { + pad_cfg->try_crop.width = fse.max_width; + pad_cfg->try_crop.height = fse.max_height; + } + ret =v4l2_subdev_call (subdev, pad, set_fmt, pad_cfg, &fmt);if (ret <0 )return ret;
@@ -588,6 +613,85 @@ static int tegra_channel_set_subdev_active_fmt(struct tegra_vi_channel *chan)return 0 ; } +static int tegra_channel_g_selection (struct file *file,void *priv, +struct v4l2_selection *sel) +{ +struct tegra_vi_channel *chan =video_drvdata (file); +struct v4l2_subdev *subdev; +struct v4l2_subdev_format fmt = { + .which =V4L2_SUBDEV_FORMAT_ACTIVE , + }; +struct v4l2_subdev_selection sdsel = { + .which =V4L2_SUBDEV_FORMAT_ACTIVE , + .target = sel->target, + }; +int ret; + + subdev =tegra_channel_get_remote_source_subdev (chan); +if (!v4l2_subdev_has_op (subdev, pad, get_selection)) +return -ENOTTY ; + +if (sel->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE ) +return -EINVAL ; +/* +* Try the get selection operation and fallback to get format if not +* implemented. +*/ + ret =v4l2_subdev_call (subdev, pad, get_selection,NULL , &sdsel); +if (!ret) + sel->r = sdsel.r; +if (ret != -ENOIOCTLCMD ) +return ret; + + ret =v4l2_subdev_call (subdev, pad, get_fmt,NULL , &fmt); +if (ret <0 ) +return ret; + + sel->r.left =0 ; + sel->r.top =0 ; + sel->r.width = fmt.format.width; + sel->r.height = fmt.format.height; + +return 0 ; +} + +static int tegra_channel_s_selection (struct file *file,void *fh, +struct v4l2_selection *sel) +{ +struct tegra_vi_channel *chan =video_drvdata (file); +struct v4l2_subdev *subdev; +int ret; +struct v4l2_subdev_selection sdsel = { + .which =V4L2_SUBDEV_FORMAT_ACTIVE , + .target = sel->target, + .flags = sel->flags, + .r = sel->r, + }; + + subdev =tegra_channel_get_remote_source_subdev (chan); +if (!v4l2_subdev_has_op (subdev, pad, set_selection)) +return -ENOTTY ; + +if (sel->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE ) +return -EINVAL ; + +if (vb2_is_busy (&chan->queue)) +return -EBUSY ; + + ret =v4l2_subdev_call (subdev, pad, set_selection,NULL , &sdsel); +if (!ret) { + sel->r = sdsel.r; +/* +* Subdev active format resolution may have changed during +* set selection operation. So, update channel format to +* the sub-device active format. +*/ +return tegra_channel_set_subdev_active_fmt (chan); + } + +return ret; +} +static int tegra_channel_enum_input (struct file *file,void *fh,struct v4l2_input *inp) {
@@ -645,6 +749,8 @@ static const struct v4l2_ioctl_ops tegra_channel_ioctl_ops = { .vidioc_streamoff = vb2_ioctl_streamoff, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, + .vidioc_g_selection = tegra_channel_g_selection, + .vidioc_s_selection = tegra_channel_s_selection, };/*
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerPATCH v8 8/10 gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
In reply to Sowjanya KomatineniWith the split of MIPI calibration into tegra_mipi_calibrate() and tegra_mipi_wait(), MIPI clock is not kept enabled till the calibration is done.
So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames tegra_mipi_calibrate() as tegra_mipi_start_calibration() and tegra_mipi_wait() as tegra_mipi_finish_calibration() to be inline with their usage.
As MIPI clock is left enabled and in case of any failures with CSI input streaming tegra_mipi_finish_calibration() will not get invoked. So added new API tegra_mipi_cancel_calibration() which disables MIPI clock and consumer drivers can call this in such cases.
--- drivers/gpu/drm/tegra/dsi.c | 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-)
drivers/gpu/drm/tegra/dsi.c +2 -2
@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi)DSI_PAD_PREEMP_PD (0x03 ) |DSI_PAD_PREEMP_PU (0x3 );tegra_dsi_writel (dsi, value,DSI_PAD_CONTROL_3 ); - err =tegra_mipi_calibrate (dsi->mipi); + err =tegra_mipi_start_calibration (dsi->mipi);if (err <0 )return err; -return tegra_mipi_wait (dsi->mipi); +return tegra_mipi_finish_calibration (dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk,
drivers/gpu/host1x/mipi.c +10 -9
@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) }EXPORT_SYMBOL (tegra_mipi_disable); -int tegra_mipi_wait (struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration (struct tegra_mipi_device *device) +{ +clk_disable (device->mipi->clk); +} +EXPORT_SYMBOL (tegra_mipi_cancel_calibration); + +int tegra_mipi_finish_calibration (struct tegra_mipi_device *device) {struct tegra_mipi *mipi = device->mipi;void __iomem *status_reg = mipi->regs + (MIPI_CAL_STATUS <<2 );u32 value;int err; - err =clk_enable (device->mipi->clk); -if (err <0 ) -return err; -mutex_lock (&device->mipi->lock); err = readl_relaxed_poll_timeout(status_reg, value,
@@ -315,9 +317,9 @@ int tegra_mipi_wait(struct tegra_mipi_device *device)return err; } -EXPORT_SYMBOL (tegra_mipi_wait); +EXPORT_SYMBOL (tegra_mipi_finish_calibration); -int tegra_mipi_calibrate (struct tegra_mipi_device *device) +int tegra_mipi_start_calibration (struct tegra_mipi_device *device) {const struct tegra_mipi_soc *soc = device->mipi->soc;unsigned int i;
@@ -382,11 +384,10 @@ int tegra_mipi_calibrate(struct tegra_mipi_device *device)tegra_mipi_writel (device->mipi, value,MIPI_CAL_CTRL );mutex_unlock (&device->mipi->lock); -clk_disable (device->mipi->clk);return 0 ; } -EXPORT_SYMBOL (tegra_mipi_calibrate); +EXPORT_SYMBOL (tegra_mipi_start_calibration);static const struct tegra_mipi_pad tegra114_mipi_pads[] = { { .data =MIPI_CAL_CONFIG_CSIA },
include/linux/host1x.h +3 -2
@@ -333,7 +333,8 @@ struct tegra_mipi_device *tegra_mipi_request(struct device *device,void tegra_mipi_free (struct tegra_mipi_device *device);int tegra_mipi_enable (struct tegra_mipi_device *device);int tegra_mipi_disable (struct tegra_mipi_device *device); -int tegra_mipi_calibrate (struct tegra_mipi_device *device); -int tegra_mipi_wait (struct tegra_mipi_device *device); +int tegra_mipi_start_calibration (struct tegra_mipi_device *device); +int tegra_mipi_finish_calibration (struct tegra_mipi_device *device); +void tegra_mipi_cancel_calibration (struct tegra_mipi_device *device);#endif
Signature · 1 line
2.7.4
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 48 lines · Sowjanya Komatineni
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration is done.So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline with their usage.As MIPI clock is left enabled and in case of any failures with CSI input streaming
tegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>--- drivers/gpu/drm/tegra/dsi.c | 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-2@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi)DSI_PAD_PREEMP_PD (0x03 ) |DSI_PAD_PREEMP_PU (0x3 );tegra_dsi_writel (dsi, value,DSI_PAD_CONTROL_3 ); - err =tegra_mipi_calibrate (dsi->mipi); + err =tegra_mipi_start_calibration (dsi->mipi);if (err <0 )return err; -return tegra_mipi_wait (dsi->mipi); +return tegra_mipi_finish_calibration (dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk,drivers/gpu/host1x/mipi.c +0
-0
drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct tegra_mipi_device *dev) · line 298
Quoted 7 lines
drivers/gpu/host1x/mipi.c +3
-1@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) }EXPORT_SYMBOL (tegra_mipi_disable); -int tegra_mipi_wait (struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration (struct tegra_mipi_device *device) +{ +clk_disable (device->mipi->clk);
Do we need to do anything with the MIPI_CAL_CTRL and MIPI_CAL_STATUS registers here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.
Thierry
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
05.08.2020 16:46, Thierry Reding пишет:
Quoted 52 lines · Sowjanya Komatineni
Quoted 51 lines
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration is done.So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline with their usage.As MIPI clock is left enabled and in case of any failures with CSI input streaming
tegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>--- drivers/gpu/drm/tegra/dsi.c | 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-2@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi)DSI_PAD_PREEMP_PD (0x03 ) |DSI_PAD_PREEMP_PU (0x3 );tegra_dsi_writel (dsi, value,DSI_PAD_CONTROL_3 ); - err =tegra_mipi_calibrate (dsi->mipi); + err =tegra_mipi_start_calibration (dsi->mipi);if (err <0 )return err; -return tegra_mipi_wait (dsi->mipi); +return tegra_mipi_finish_calibration (dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk,drivers/gpu/host1x/mipi.c +0
-0@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) }EXPORT_SYMBOL (tegra_mipi_disable);
Quoted 10 lines
drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct tegra_mipi_device *dev) · line 298
Quoted 4 lines
drivers/gpu/host1x/mipi.c +3
-1-int tegra_mipi_wait (struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration (struct tegra_mipi_device *device) +{ +clk_disable (device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUSregisters here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.
Apparently there is no way to explicitly stop calibration other than to reset MIPI calibration block, but Sowjanya says this is unnecessary.
Perhaps having a fixed delay before disabling clock could be enough to ensure that calibration is stopped before the clock is disabled?
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
05.08.2020 17:05, Dmitry Osipenko пишет:
Quoted 64 lines
05.08.2020 16:46, Thierry Reding пишет:
Quoted 52 lines · Sowjanya Komatineni
Quoted 51 lines
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration is done.So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline with their usage.As MIPI clock is left enabled and in case of any failures with CSI input streaming
tegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>--- drivers/gpu/drm/tegra/dsi.c | 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-2@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi)DSI_PAD_PREEMP_PD (0x03 ) |DSI_PAD_PREEMP_PU (0x3 );tegra_dsi_writel (dsi, value,DSI_PAD_CONTROL_3 ); - err =tegra_mipi_calibrate (dsi->mipi); + err =tegra_mipi_start_calibration (dsi->mipi);if (err <0 )return err; -return tegra_mipi_wait (dsi->mipi); +return tegra_mipi_finish_calibration (dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk,drivers/gpu/host1x/mipi.c +0
-0@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) }EXPORT_SYMBOL (tegra_mipi_disable);Quoted 10 lines
drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct tegra_mipi_device *dev) · line 298
Quoted 4 lines
drivers/gpu/host1x/mipi.c +3
-1-int tegra_mipi_wait (struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration (struct tegra_mipi_device *device) +{ +clk_disable (device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUSregisters here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.
Quoted 6 lines
Apparently there is no way to explicitly stop calibration other than to reset MIPI calibration block, but Sowjanya says this is unnecessary.
Perhaps having a fixed delay before disabling clock could be enough to ensure that calibration is stopped before the clock is disabled?
Actually, there is a MIPI_CAL_ACTIVE bit in the status register. Maybe it needs to be polled until it's unset?
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 63 lines · Dmitry Osipenko
05.08.2020 17:05, Dmitry Osipenko пишет:
Quoted 62 lines
05.08.2020 16:46, Thierry Reding пишет:
Quoted 61 lines · Sowjanya Komatineni
Quoted 48 lines
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration is done.So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline with their usage.As MIPI clock is left enabled and in case of any failures with CSI input streaming
tegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>--- drivers/gpu/drm/tegra/dsi.c | 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-2@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi)DSI_PAD_PREEMP_PD (0x03 ) |DSI_PAD_PREEMP_PU (0x3 );tegra_dsi_writel (dsi, value,DSI_PAD_CONTROL_3 ); - err =tegra_mipi_calibrate (dsi->mipi); + err =tegra_mipi_start_calibration (dsi->mipi);if (err <0 )return err; -return tegra_mipi_wait (dsi->mipi); +return tegra_mipi_finish_calibration (dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk,drivers/gpu/host1x/mipi.c +0
-0drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct tegra_mipi_device *dev) · line 298
Quoted 7 lines
drivers/gpu/host1x/mipi.c +3
-1@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) }EXPORT_SYMBOL (tegra_mipi_disable); -int tegra_mipi_wait (struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration (struct tegra_mipi_device *device) +{ +clk_disable (device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUSregisters here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.
Quoted 8 lines
Quoted 6 lines
Apparently there is no way to explicitly stop calibration other than to reset MIPI calibration block, but Sowjanya says this is unnecessary.
Perhaps having a fixed delay before disabling clock could be enough to ensure that calibration is stopped before the clock is disabled?
Actually, there is a
MIPI_CAL_ACTIVEbit in the status register. Maybe it needs to be polled until it's unset?
Confirmed with HW design team during this patch update.
SW does not need to clear START bit and only write 1 takes effect to that bit.
Also, no need to have delay or do any other register settings unclear as its FSM and there's nothing to get stuck.
Also it goes thru small finite set of codes and by the time sensor programming happens for enabling streaming FSM will finish its calibration sequence much early and it will only wait for pads LP-11.
So, during cancel we only need disable MIPI clock.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
05.08.2020 19:33, Sowjanya Komatineni пишет:
Quoted 81 lines · Dmitry Osipenko
Quoted 65 lines
05.08.2020 17:05, Dmitry Osipenko пишет:
Quoted 64 lines
05.08.2020 16:46, Thierry Reding пишет:
Quoted 63 lines · Sowjanya Komatineni
Quoted 50 lines
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration is done.So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()
andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline with their usage.As MIPI clock is left enabled and in case of any failures with CSI input
streamingtegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock
and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>---
drivers/gpu/drm/tegra/dsi.c| 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++--3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-0@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); - err = tegra_mipi_calibrate(dsi->mipi); + err = tegra_mipi_start_calibration(dsi->mipi); if (err < 0) return err; - return tegra_mipi_wait(dsi->mipi); + return tegra_mipi_finish_calibration(dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi,unsigned long bclk,
drivers/gpu/host1x/mipi.c +0
-0drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct · line 299
Quoted 7 lines
drivers/gpu/host1x/mipi.c +3
-0@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) } EXPORT_SYMBOL(tegra_mipi_disable); -int tegra_mipi_wait(struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration(struct tegra_mipi_device *device) +{ + clk_disable(device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUSregisters here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.Quoted 8 lines
Quoted 6 lines
Apparently there is no way to explicitly stop calibration other than to reset MIPI calibration block, but Sowjanya says this is unnecessary.
Perhaps having a fixed delay before disabling clock could be enough to ensure that calibration is stopped before the clock is disabled?
Actually, there is a
MIPI_CAL_ACTIVEbit in the status register. Maybe it needs to be polled until it's unset?Confirmed with HW design team during this patch update.
SW does not need to clear START bit and only write 1 takes effect to that bit.
Quoted 9 lines
Also, no need to have delay or do any other register settings unclear as its FSM and there's nothing to get stuck.
Also it goes thru small finite set of codes and by the time sensor programming happens for enabling streaming FSM will finish its calibration sequence much early and it will only wait for pads LP-11.
So, during cancel we only need disable MIPI clock.
But there is no guarantee that cancel_calibration() couldn't be invoked in the middle of the calibration process, hence FSM could freeze in an intermediate state if it's running on the disabled MIPI clock, this doesn't sound good.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 87 lines · Dmitry Osipenko
05.08.2020 19:33, Sowjanya Komatineni пишет:
Quoted 86 lines · Dmitry Osipenko
Quoted 65 lines
05.08.2020 17:05, Dmitry Osipenko пишет:
Quoted 64 lines
05.08.2020 16:46, Thierry Reding пишет:
Quoted 63 lines · Sowjanya Komatineni
Quoted 50 lines
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration is done.So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()
andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline with their usage.As MIPI clock is left enabled and in case of any failures with CSI input
streamingtegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock
and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>--- drivers/gpu/drm/tegra/dsi.c | 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-0@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); - err = tegra_mipi_calibrate(dsi->mipi); + err = tegra_mipi_start_calibration(dsi->mipi); if (err < 0) return err; - return tegra_mipi_wait(dsi->mipi); + return tegra_mipi_finish_calibration(dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi,unsigned long bclk,
drivers/gpu/host1x/mipi.c +0
-0drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct · line 299
Quoted 7 lines
drivers/gpu/host1x/mipi.c +3
-0@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) } EXPORT_SYMBOL(tegra_mipi_disable); -int tegra_mipi_wait(struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration(struct tegra_mipi_device *device) +{ + clk_disable(device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUSregisters here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.Quoted 8 lines
Quoted 6 lines
Apparently there is no way to explicitly stop calibration other than to reset MIPI calibration block, but Sowjanya says this is unnecessary.
Perhaps having a fixed delay before disabling clock could be enough to ensure that calibration is stopped before the clock is disabled?
Actually, there is a
MIPI_CAL_ACTIVEbit in the status register. Maybe it needs to be polled until it's unset?Confirmed with HW design team during this patch update.
SW does not need to clear START bit and only write 1 takes effect to that bit.
Also, no need to have delay or do any other register settings unclear as its FSM and there's nothing to get stuck.
Also it goes thru small finite set of codes and by the time sensor programming happens for enabling streaming FSM will finish its calibration sequence much early and it will only wait for pads LP-11.
Quoted 6 lines
Quoted 2 lines
So, during cancel we only need disable MIPI clock.
But there is no guarantee that
cancel_calibration()couldn't be invoked in the middle of the calibration process, hence FSM could freeze in an intermediate state if it's running on the disabled MIPI clock, this doesn't sound good.
Actual calibration logic uses UART_FST_CAL clock which is always enabled
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
05.08.2020 19:50, Sowjanya Komatineni пишет:
Quoted 94 lines · Dmitry Osipenko
Quoted 92 lines
05.08.2020 19:33, Sowjanya Komatineni пишет:
Quoted 91 lines · Dmitry Osipenko
Quoted 73 lines
05.08.2020 17:05, Dmitry Osipenko пишет:
Quoted 72 lines
05.08.2020 16:46, Thierry Reding пишет:
Quoted 59 lines · Sowjanya Komatineni
Quoted 58 lines
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration
is done.So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()
andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline
with their usage.As MIPI clock is left enabled and in case of any failures with CSI input
streamingtegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock
and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>---
drivers/gpu/drm/tegra/dsi.c| 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++--3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-0@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); - err = tegra_mipi_calibrate(dsi->mipi); + err = tegra_mipi_start_calibration(dsi->mipi); if (err < 0) return err; - return tegra_mipi_wait(dsi->mipi); + return tegra_mipi_finish_calibration(dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi,unsigned long bclk,
drivers/gpu/host1x/mipi.c +1
-0@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) } EXPORT_SYMBOL(tegra_mipi_disable); -int tegra_mipi_wait(struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration(struct tegra_mipi_deviceQuoted 8 lines
drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct · line 300
Quoted 3 lines
drivers/gpu/host1x/mipi.c +2
-0*device) +{ + clk_disable(device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUSregisters here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.Apparently there is no way to explicitly stop calibration other than to
reset MIPI calibration block, but Sowjanya says this is unnecessary.Quoted 5 lines
Quoted 3 lines
Perhaps having a fixed delay before disabling clock could be enough to ensure that calibration is stopped before the clock is disabled?
Actually, there is a
MIPI_CAL_ACTIVEbit in the status register. Maybe it needs to be polled until it's unset?Confirmed with HW design team during this patch update.
SW does not need to clear START bit and only write 1 takes effect to that bit.
Also, no need to have delay or do any other register settings unclear as its FSM and there's nothing to get stuck.
Also it goes thru small finite set of codes and by the time sensor programming happens for enabling streaming FSM will finish its calibration sequence much early and it will only wait for pads LP-11.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
So, during cancel we only need disable MIPI clock.
But there is no guarantee that
cancel_calibration()couldn't be invoked in the middle of the calibration process, hence FSM could freeze in an intermediate state if it's running on the disabled MIPI clock, this doesn't sound good.Actual calibration logic uses
UART_FST_CALclock which is always enabled
What enables the UART_FST_CAL clock? I don't see this clock used anywhere.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 94 lines · Dmitry Osipenko
05.08.2020 19:50, Sowjanya Komatineni пишет:
Quoted 93 lines · Dmitry Osipenko
Quoted 92 lines
05.08.2020 19:33, Sowjanya Komatineni пишет:
Quoted 91 lines · Dmitry Osipenko
Quoted 73 lines
05.08.2020 17:05, Dmitry Osipenko пишет:
Quoted 72 lines
05.08.2020 16:46, Thierry Reding пишет:
Quoted 59 lines · Sowjanya Komatineni
Quoted 58 lines
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration
is done.So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()
andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline
with their usage.As MIPI clock is left enabled and in case of any failures with CSI input
streamingtegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock
and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>--- drivers/gpu/drm/tegra/dsi.c | 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-0@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); - err = tegra_mipi_calibrate(dsi->mipi); + err = tegra_mipi_start_calibration(dsi->mipi); if (err < 0) return err; - return tegra_mipi_wait(dsi->mipi); + return tegra_mipi_finish_calibration(dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi,unsigned long bclk,
drivers/gpu/host1x/mipi.c +1
-0@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) } EXPORT_SYMBOL(tegra_mipi_disable); -int tegra_mipi_wait(struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration(struct tegra_mipi_deviceQuoted 8 lines
drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct · line 300
Quoted 3 lines
drivers/gpu/host1x/mipi.c +2
-0*device) +{ + clk_disable(device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUSregisters here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.Apparently there is no way to explicitly stop calibration other than to
reset MIPI calibration block, but Sowjanya says this is unnecessary.Quoted 5 lines
Quoted 3 lines
Perhaps having a fixed delay before disabling clock could be enough to ensure that calibration is stopped before the clock is disabled?
Actually, there is a
MIPI_CAL_ACTIVEbit in the status register. Maybe it needs to be polled until it's unset?Confirmed with HW design team during this patch update.
SW does not need to clear START bit and only write 1 takes effect to that bit.
Also, no need to have delay or do any other register settings unclear as its FSM and there's nothing to get stuck.
Also it goes thru small finite set of codes and by the time sensor programming happens for enabling streaming FSM will finish its calibration sequence much early and it will only wait for pads LP-11.
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
So, during cancel we only need disable MIPI clock.
But there is no guarantee that
cancel_calibration()couldn't be invoked in the middle of the calibration process, hence FSM could freeze in an intermediate state if it's running on the disabled MIPI clock, this doesn't sound good.Actual calibration logic uses
UART_FST_CALclock which is always enabledWhat enables the
UART_FST_CALclock? I don't see this clock used anywhere.
UART_FST_MIPI_CAL is shared with uart and is always enabled all the time.
I don't see mipi driver handling this and I think that's because this clock is enabled all the time as its used for UART as well. Probably thierry can comment on this clock.
Also regarding cancel calibration, as FSM goes thru only finite sequence codes by the time csi stream and sensor stream happens which is where we check for calibration to complete for sure calibration will be finished and calibration logic will only wait for pads to be in LP-11 to apply results. So nothing special needed during cancel except to turn clock off to balance its usage count.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
05.08.2020 20:04, Sowjanya Komatineni пишет:
Quoted 110 lines · Dmitry Osipenko
Quoted 108 lines
05.08.2020 19:50, Sowjanya Komatineni пишет:
Quoted 107 lines · Dmitry Osipenko
Quoted 99 lines
05.08.2020 19:33, Sowjanya Komatineni пишет:
Quoted 98 lines · Dmitry Osipenko
Quoted 77 lines
05.08.2020 17:05, Dmitry Osipenko пишет:
Quoted 76 lines
05.08.2020 16:46, Thierry Reding пишет:
Quoted 63 lines
Quoted 61 lines · Sowjanya Komatineni
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration
is done.So, this patch skips disabling MIPI clock after triggering start of
calibration and disables it only after waiting for done status from
the calibration logic.This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()
andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline
with their usage.As MIPI clock is left enabled and in case of any failures with CSI input
streamingtegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock
and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>---
drivers/gpu/drm/tegra/dsi.c| 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++--3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-0@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); - err = tegra_mipi_calibrate(dsi->mipi); + err = tegra_mipi_start_calibration(dsi->mipi); if (err < 0) return err; - return tegra_mipi_wait(dsi->mipi); + return tegra_mipi_finish_calibration(dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi,unsigned long bclk,
drivers/gpu/host1x/mipi.c +1
-0@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) } EXPORT_SYMBOL(tegra_mipi_disable); -int tegra_mipi_wait(struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration(struct tegra_mipi_device *device)Quoted 8 lines
drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct · line 300
Quoted 2 lines
drivers/gpu/host1x/mipi.c +2
-0+{ + clk_disable(device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUS
registers here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.Apparently there is no way to explicitly stop calibration other than to
reset MIPI calibration block, but Sowjanya says this is unnecessary.Quoted 7 lines
Quoted 4 lines
Perhaps having a fixed delay before disabling clock could be enough to
ensure that calibration is stopped before the clock is disabled?Actually, there is a
MIPI_CAL_ACTIVEbit in the status register. Maybe
it needs to be polled until it's unset?Confirmed with HW design team during this patch update.
SW does not need to clear START bit and only write 1 takes effect to that bit.
Also, no need to have delay or do any other register settings unclear as
its FSM and there's nothing to get stuck.Also it goes thru small finite set of codes and by the time sensor programming happens for enabling streaming FSM will finish its calibration sequence much early and it will only wait for pads LP-11.
Quoted 6 lines
Quoted 2 lines
So, during cancel we only need disable MIPI clock.
But there is no guarantee that
cancel_calibration()couldn't be invoked in the middle of the calibration process, hence FSM could freeze in an intermediate state if it's running on the disabled MIPI clock, this doesn't sound good.Actual calibration logic uses
UART_FST_CALclock which is always enabled
Quoted 8 lines
Quoted 2 lines
What enables the
UART_FST_CALclock? I don't see this clock used anywhere.
UART_FST_MIPI_CALis shared with uart and is always enabled all the time.I don't see mipi driver handling this and I think that's because this clock is enabled all the time as its used for UART as well. Probably thierry can comment on this clock.
It's not only the MIPI driver, the clock isn't defined at all neither in the clk driver, nor in clk DT bindings.
It could be fragile to assume that it's always enabled.
Quoted 6 lines
Also regarding cancel calibration, as FSM goes thru only finite sequence codes by the time csi stream and sensor stream happens which is where we check for calibration to complete for sure calibration will be finished and calibration logic will only wait for pads to be in LP-11 to apply results. So nothing special needed during cancel except to turn clock off to balance its usage count.
I guess it should be okay for the case of the VI driver, but in general please don't assume that code can't change in the future. The common API always should be made reliable for all possible situations.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 114 lines · Dmitry Osipenko
05.08.2020 20:04, Sowjanya Komatineni пишет:
Quoted 113 lines · Dmitry Osipenko
Quoted 103 lines
05.08.2020 19:50, Sowjanya Komatineni пишет:
Quoted 102 lines · Dmitry Osipenko
Quoted 101 lines
05.08.2020 19:33, Sowjanya Komatineni пишет:
Quoted 100 lines · Dmitry Osipenko
Quoted 77 lines
05.08.2020 17:05, Dmitry Osipenko пишет:
Quoted 76 lines
05.08.2020 16:46, Thierry Reding пишет:
Quoted 63 lines
Quoted 61 lines · Sowjanya Komatineni
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration
is done.So, this patch skips disabling MIPI clock after triggering start of
calibration and disables it only after waiting for done status from
the calibration logic.This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()
andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline
with their usage.As MIPI clock is left enabled and in case of any failures with CSI input
streamingtegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock
and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>--- drivers/gpu/drm/tegra/dsi.c | 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-0@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); - err = tegra_mipi_calibrate(dsi->mipi); + err = tegra_mipi_start_calibration(dsi->mipi); if (err < 0) return err; - return tegra_mipi_wait(dsi->mipi); + return tegra_mipi_finish_calibration(dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi,unsigned long bclk,
drivers/gpu/host1x/mipi.c +1
-0@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) } EXPORT_SYMBOL(tegra_mipi_disable); -int tegra_mipi_wait(struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration(struct tegra_mipi_device *device)Quoted 8 lines
drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct · line 300
Quoted 2 lines
drivers/gpu/host1x/mipi.c +2
-0+{ + clk_disable(device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUS
registers here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.Apparently there is no way to explicitly stop calibration other than to
reset MIPI calibration block, but Sowjanya says this is unnecessary.Quoted 7 lines
Quoted 4 lines
Perhaps having a fixed delay before disabling clock could be enough to
ensure that calibration is stopped before the clock is disabled?Actually, there is a
MIPI_CAL_ACTIVEbit in the status register. Maybe
it needs to be polled until it's unset?Confirmed with HW design team during this patch update.
SW does not need to clear START bit and only write 1 takes effect to that bit.
Also, no need to have delay or do any other register settings unclear as
its FSM and there's nothing to get stuck.Also it goes thru small finite set of codes and by the time sensor programming happens for enabling streaming FSM will finish its calibration sequence much early and it will only wait for pads LP-11.
So, during cancel we only need disable MIPI clock.
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
But there is no guarantee that
cancel_calibration()couldn't be invoked in the middle of the calibration process, hence FSM could freeze in an intermediate state if it's running on the disabled MIPI clock, this doesn't sound good.Actual calibration logic uses
UART_FST_CALclock which is always enabledWhat enables the
UART_FST_CALclock? I don't see this clock used anywhere.
UART_FST_MIPI_CALis shared with uart and is always enabled all the time.
Quoted 7 lines
Quoted 3 lines
I don't see mipi driver handling this and I think that's because this clock is enabled all the time as its used for UART as well. Probably thierry can comment on this clock.
It's not only the MIPI driver, the clock isn't defined at all neither in the clk driver, nor in clk DT bindings.
It could be fragile to assume that it's always enabled.
From SW clock architecture this clock is always kept programmed to 68Mhz and enabled.
Its shared clock for UART and I see it enabled.
Thierry can comment more on where this clock is being handled? prior to kernel?
Quoted 10 lines
Quoted 7 lines
Also regarding cancel calibration, as FSM goes thru only finite sequence codes by the time csi stream and sensor stream happens which is where we check for calibration to complete for sure calibration will be finished and calibration logic will only wait for pads to be in LP-11 to apply results. So nothing special needed during cancel except to turn clock off to balance its usage count.
I guess it should be okay for the case of the VI driver, but in general please don't assume that code can't change in the future. The common API always should be made reliable for all possible situations.
Yes, There is no assumption here.
Just to be clear, UART_FST_MIPI_CAL is the clock used for calibration logic which is FSM that goes thru sequence codes and when done waits for pads to be in LP-11 to apply results.
MIPI_CLK is controller gate clock which is also need to be kept enabled as in case if it sees LP-11 it updates registers so its recommended to have this clock enabled during calibration process.
In case of CSI pads calibration, we call cancel_calibration() only when csi/sensor stream on fails and in which case there will be no LP-11 so we can unconditionally disable MIPI_CLK.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
In reply to Sowjanya KomatineniQuoted 102 lines · Sowjanya Komatineni
Quoted 100 lines · Dmitry Osipenko
05.08.2020 19:50, Sowjanya Komatineni пишет:
Quoted 99 lines · Dmitry Osipenko
Quoted 98 lines
05.08.2020 19:33, Sowjanya Komatineni пишет:
Quoted 84 lines · Dmitry Osipenko
Quoted 73 lines
05.08.2020 17:05, Dmitry Osipenko пишет:
Quoted 72 lines
05.08.2020 16:46, Thierry Reding пишет:
Quoted 59 lines · Sowjanya Komatineni
Quoted 58 lines
With the split of MIPI calibration into
tegra_mipi_calibrate()andtegra_mipi_wait(), MIPI clock is not kept enabled till the calibration
is done.So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic.
This patch renames
tegra_mipi_calibrate()astegra_mipi_start_calibration()
andtegra_mipi_wait()astegra_mipi_finish_calibration()to be inline
with their usage.As MIPI clock is left enabled and in case of any failures with CSI input
streamingtegra_mipi_finish_calibration()will not get invoked. So added new APItegra_mipi_cancel_calibration()which disables MIPI clock
and consumer drivers can call this in such cases.Reviewed-by Dmitry Osipenko <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>---
drivers/gpu/drm/tegra/dsi.c| 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++--3 files changed, 15 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dsi.c +2
-0@@ -694,11 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); - err = tegra_mipi_calibrate(dsi->mipi); + err = tegra_mipi_start_calibration(dsi->mipi); if (err < 0) return err; - return tegra_mipi_wait(dsi->mipi); + return tegra_mipi_finish_calibration(dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi,unsigned long bclk,
drivers/gpu/host1x/mipi.c +1
-0@@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) } EXPORT_SYMBOL(tegra_mipi_disable); -int tegra_mipi_wait(struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration(struct tegra_mipi_deviceQuoted 8 lines
drivers/gpu/host1x/mipi.c int tegra_mipi_disable(struct · line 300
Quoted 3 lines
drivers/gpu/host1x/mipi.c +2
-0*device) +{ + clk_disable(device->mipi->clk);Do we need to do anything with the
MIPI_CAL_CTRLandMIPI_CAL_STATUSregisters here? We don't clear the START bit in the former when the calibration has successfully finished, but I suspect that's because the bit is self-clearing. But I wonder if we still need to clear it upon cancellation to make sure the calibration does indeed stop.Apparently there is no way to explicitly stop calibration other than to
reset MIPI calibration block, but Sowjanya says this is unnecessary.Quoted 5 lines
Quoted 3 lines
Perhaps having a fixed delay before disabling clock could be enough to ensure that calibration is stopped before the clock is disabled?
Actually, there is a
MIPI_CAL_ACTIVEbit in the status register. Maybe it needs to be polled until it's unset?Confirmed with HW design team during this patch update.
SW does not need to clear START bit and only write 1 takes effect to that bit.
Quoted 9 lines
Also, no need to have delay or do any other register settings unclear as its FSM and there's nothing to get stuck.
Also it goes thru small finite set of codes and by the time sensor programming happens for enabling streaming FSM will finish its calibration sequence much early and it will only wait for pads LP-11.
So, during cancel we only need disable MIPI clock.
But there is no guarantee that
cancel_calibration()couldn't be invoked in the middle of the calibration process, hence FSM could freeze in an intermediate state if it's running on the disabled MIPI clock, this doesn't sound good.
Quoted 10 lines
Quoted 2 lines
Quoted 1 line
Actual calibration logic uses
UART_FST_CALclock which is always enabledWhat enables the
UART_FST_CALclock? I don't see this clock used anywhere.
UART_FST_MIPI_CALis shared with uart and is always enabled all the time.I don't see mipi driver handling this and I think that's because this clock is enabled all the time as its used for UART as well. Probably thierry can comment on this clock.
Also regarding cancel calibration, as FSM goes thru only finite sequence codes by the time csi stream and sensor stream happens which is where we check for calibration to complete for sure calibration will be finished and calibration logic will only wait for pads to be in LP-11 to apply results. So nothing special needed during cancel except to turn clock off to balance its usage count.
UART_FST_MIPI_CAL is the clock used for calibration logic which is FSM that goes thru sequence codes and when done waits for pads to be in LP-11 to apply results.
MIPI_CLK is controller gate clock which is also need to be kept enabled as incase if it sees LP-11 it updates registers so its recommended to have this clock enabled.
We can cancel_calibration() in CSI only when csi/sensor stream on fails and in which case there will be no LP-11 so we can unconditionally disable MIPI_CLK.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
05.08.2020 20:29, Sowjanya Komatineni пишет:
...
Quoted 4 lines
UART_FST_MIPI_CALis the clock used for calibration logic which is FSM that goes thru sequence codes and when done waits for pads to be in LP-11 to apply results.
Quoted 8 lines
MIPI_CLKis controller gate clock which is also need to be kept enabled as incase if it sees LP-11 it updates registers so its recommended to have this clock enabled.We can
cancel_calibration()in CSI only when csi/sensor stream on fails and in which case there will be no LP-11 so we can unconditionally disableMIPI_CLK.
There is no guarantee that the fail comes before the LP-11. For example, some odd camera driver may have a complicated enable sequence which may fail after enabling the hardware streaming.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 10 lines · Dmitry Osipenko
05.08.2020 20:29, Sowjanya Komatineni пишет:
...Quoted 8 lines
UART_FST_MIPI_CALis the clock used for calibration logic which is FSM that goes thru sequence codes and when done waits for pads to be in LP-11 to apply results.
MIPI_CLKis controller gate clock which is also need to be kept enabled as incase if it sees LP-11 it updates registers so its recommended to have this clock enabled.
Quoted 7 lines
Quoted 4 lines
We can
cancel_calibration()in CSI only when csi/sensor stream on fails and in which case there will be no LP-11 so we can unconditionally disableMIPI_CLK.There is no guarantee that the fail comes before the LP-11. For example, some odd camera driver may have a complicated enable sequence which may fail after enabling the hardware streaming.
MIPI_CLK to keep enable is for calibration logic to update results, but like I said calibration logic uses UART_FST_MIPI_CAL clock. So even in case if fail happens from sensor after having pads in LP-11 then, calibration logic will still be running but result update will not happen with clock disabled. But HW will not stuck as this is confirmed from HW designer.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 16 lines · Sowjanya Komatineni
Quoted 14 lines · Dmitry Osipenko
05.08.2020 20:29, Sowjanya Komatineni пишет:
...Quoted 12 lines
UART_FST_MIPI_CALis the clock used for calibration logic which is FSM that goes thru sequence codes and when done waits for pads to be in LP-11 to apply results.
MIPI_CLKis controller gate clock which is also need to be kept enabled as incase if it sees LP-11 it updates registers so its recommended to have this clock enabled.We can
cancel_calibration()in CSI only when csi/sensor stream on fails and in which case there will be no LP-11 so we can unconditionally disableMIPI_CLK.
Quoted 5 lines
Quoted 3 lines
There is no guarantee that the fail comes before the LP-11. For example, some odd camera driver may have a complicated enable sequence which may fail after enabling the hardware streaming.
MIPI_CLKto keep enable is for calibration logic to update results, but like I said calibration logic usesUART_FST_MIPI_CALclock. So even in case if fail happens from sensor after having pads in LP-11 then, calibration logic will still be running but result update will not happen with clock disabled. But HW will not stuck as this is confirmed from HW designer.
If LP-11 happens from sensor stream (followed by fail) and by that time if calibration FSM is done and if calibration logic sees LP-11 then results will be applied to pads.
We did start of calibration before CSI stream so by the time we do sensor stream enable, calibration logic might have done with FSM and waiting for LP-11
Also if we see any special case, we always can use finish_calibration() instead of cancel_calibration() as well.
finish_calibration() has extra 250ms wait time polling done bit and we can ignore its return code during fail pathway.
Quoted 3 lines
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 24 lines · Sowjanya Komatineni
Quoted 16 lines · Sowjanya Komatineni
Quoted 14 lines · Dmitry Osipenko
05.08.2020 20:29, Sowjanya Komatineni пишет:
...Quoted 12 lines
UART_FST_MIPI_CALis the clock used for calibration logic which is FSM that goes thru sequence codes and when done waits for pads to be in LP-11 to apply results.
MIPI_CLKis controller gate clock which is also need to be kept enabled as incase if it sees LP-11 it updates registers so its recommended to have this clock enabled.We can
cancel_calibration()in CSI only when csi/sensor stream on fails and in which case there will be no LP-11 so we can unconditionally disableMIPI_CLK.Quoted 5 lines
Quoted 3 lines
There is no guarantee that the fail comes before the LP-11. For example, some odd camera driver may have a complicated enable sequence which may fail after enabling the hardware streaming.
MIPI_CLKto keep enable is for calibration logic to update results, but like I said calibration logic usesUART_FST_MIPI_CALclock. So even in case if fail happens from sensor after having pads in LP-11 then, calibration logic will still be running but result update will not happen with clock disabled. But HW will not stuck as this is confirmed from HW designer.
Quoted 8 lines
If LP-11 happens from sensor stream (followed by fail) and by that time if calibration FSM is done and if calibration logic sees LP-11 then results will be applied to pads.
We did start of calibration before CSI stream so by the time we do sensor stream enable, calibration logic might have done with FSM and waiting for LP-11
Also if we see any special case, we always can use
finish_calibration()instead ofcancel_calibration()as well.
finish_calibration()has extra 250ms wait time polling done bit and we can ignore its return code during fail pathway.
Confirmed from HW designer, calibration FSM to finish takes worst case 72uS so by the time it gets to sensor stream it will be done its sequence and will be waiting for DONE bit.
So disabling MIPI CAL clock on sensor stream fails is safe.
Quoted 3 lines
Quoted 3 lines
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
06.08.2020 03:47, Sowjanya Komatineni пишет:
Quoted 38 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 23 lines · Dmitry Osipenko
Quoted 16 lines
05.08.2020 20:29, Sowjanya Komatineni пишет:
...Quoted 9 lines
UART_FST_MIPI_CALis the clock used for calibration logic which is FSM that goes thru sequence codes and when done waits for pads to be in LP-11 to apply results.
MIPI_CLKis controller gate clock which is also need to be kept enabled
as incase if it sees LP-11 it updates registers so its recommended to have this clock enabled.Quoted 5 lines
We can
cancel_calibration()in CSI only when csi/sensor stream on fails
and in which case there will be no LP-11 so we can unconditionally disableMIPI_CLK.Quoted 4 lines
There is no guarantee that the fail comes before the LP-11. For example,
some odd camera driver may have a complicated enable sequence which may fail after enabling the hardware streaming.Quoted 6 lines
MIPI_CLKto keep enable is for calibration logic to update results, but like I said calibration logic usesUART_FST_MIPI_CALclock. So even in case if fail happens from sensor after having pads in LP-11 then, calibration logic will still be running but result update will not happen with clock disabled. But HW will not stuck as this is confirmed from HW designer.If LP-11 happens from sensor stream (followed by fail) and by that time if calibration FSM is done and if calibration logic sees LP-11 then results will be applied to pads.
Quoted 6 lines
Quoted 6 lines
We did start of calibration before CSI stream so by the time we do sensor stream enable, calibration logic might have done with FSM and waiting for LP-11
Also if we see any special case, we always can use
finish_calibration()instead ofcancel_calibration()as well.
Why not to do it right now?
Then the code could look like this:
src_subdev = tegra_channel_get_remote_source_subdev(chan); ret = v4l2_subdev_call(src_subdev, video, s_stream, true); err = tegra_mipi_finish_calibration(csi_chan->mipi);
if (ret < 0 && ret != -ENOIOCTLCMD)
goto err_disable_csi_stream;
if (err < 0)
dev_warn(csi_chan->csi->dev, "MIPI calibration failed: %d\n", err);
Quoted 8 lines
Quoted 3 lines
finish_calibration()has extra 250ms wait time polling done bit and we can ignore its return code during fail pathway.Confirmed from HW designer, calibration FSM to finish takes worst case 72uS so by the time it gets to sensor stream it will be done its sequence and will be waiting for DONE bit.
So disabling MIPI CAL clock on sensor stream fails is safe.
72us is quite a lot of time, what will happen if LP-11 happens before FSM finished calibration?
Maybe the finish_calibration() needs to split into two parts:
1. wait for CAL_STATUS_ACTIVE before enabling sensor
2. wait for CAL_STATUS_DONE after enabling sensor
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 64 lines · Dmitry Osipenko
06.08.2020 03:47, Sowjanya Komatineni пишет:
Quoted 33 lines · Sowjanya Komatineni
Quoted 32 lines · Sowjanya Komatineni
Quoted 21 lines · Dmitry Osipenko
Quoted 16 lines
05.08.2020 20:29, Sowjanya Komatineni пишет:
...Quoted 9 lines
UART_FST_MIPI_CALis the clock used for calibration logic which is FSM that goes thru sequence codes and when done waits for pads to be in LP-11 to apply results.
MIPI_CLKis controller gate clock which is also need to be kept enabled
as incase if it sees LP-11 it updates registers so its recommended to have this clock enabled.Quoted 5 lines
We can
cancel_calibration()in CSI only when csi/sensor stream on fails
and in which case there will be no LP-11 so we can unconditionally disableMIPI_CLK.Quoted 4 lines
There is no guarantee that the fail comes before the LP-11. For example,
some odd camera driver may have a complicated enable sequence which may fail after enabling the hardware streaming.Quoted 6 lines
MIPI_CLKto keep enable is for calibration logic to update results, but like I said calibration logic usesUART_FST_MIPI_CALclock. So even in case if fail happens from sensor after having pads in LP-11 then, calibration logic will still be running but result update will not happen with clock disabled. But HW will not stuck as this is confirmed from HW designer.If LP-11 happens from sensor stream (followed by fail) and by that time if calibration FSM is done and if calibration logic sees LP-11 then results will be applied to pads.
Quoted 6 lines
Quoted 6 lines
We did start of calibration before CSI stream so by the time we do sensor stream enable, calibration logic might have done with FSM and waiting for LP-11
Also if we see any special case, we always can use
finish_calibration()instead ofcancel_calibration()as well.Why not to do it right now?
Then the code could look like this:
src_subdev=tegra_channel_get_remote_source_subdev(chan); ret =v4l2_subdev_call(src_subdev, video, s_stream, true); err =tegra_mipi_finish_calibration(csi_chan->mipi);if (ret < 0 && ret !=
-ENOIOCTLCMD)goto err_disable_csi_stream;if (err < 0)
dev_warn(csi_chan->csi->dev, "MIPI calibration failed: %d\n", err);Quoted 8 lines
Quoted 3 lines
finish_calibration()has extra 250ms wait time polling done bit and we can ignore its return code during fail pathway.Confirmed from HW designer, calibration FSM to finish takes worst case 72uS so by the time it gets to sensor stream it will be done its sequence and will be waiting for DONE bit.
So disabling MIPI CAL clock on sensor stream fails is safe.
Quoted 7 lines
72us is quite a lot of time, what will happen if LP-11 happens before FSM finished calibration?
Maybe the
finish_calibration()needs to split into two parts:1. wait for
CAL_STATUS_ACTIVEbefore enabling sensor
2. wait forCAL_STATUS_DONEafter enabling sensor
I don't think we need to split for active and done. Active will be 1 as long as other pads are in calibration as well.
We cant use active status check for specific pads under calibration. This is common bit for all pads.
Unfortunately HW don't have separate status indicating when sequence is done to indicate its waiting for LP11.
To avoid all this, will remove cancel_calibration() totally and use same finish calibration even in case of stream failure then.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
06.08.2020 18:59, Sowjanya Komatineni пишет:
..
Quoted 2 lines
We cant use active status check for specific pads under calibration. This is common bit for all pads.
I'm not sure why this is a problem.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
06.08.2020 19:13, Dmitry Osipenko пишет:
Quoted 7 lines
06.08.2020 18:59, Sowjanya Komatineni пишет:
..Quoted 2 lines
We cant use active status check for specific pads under calibration. This is common bit for all pads.
I'm not sure why this is a problem.
IIUC, the start_calibration() should wait for the MIPI_CAL_STATUS_ACTIVE and finish_calibration() should wait for MIPI_AUTO_CAL_DONE_CSIA/B.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 9 lines · Dmitry Osipenko
06.08.2020 19:13, Dmitry Osipenko пишет:
Quoted 6 lines
06.08.2020 18:59, Sowjanya Komatineni пишет:
..Quoted 2 lines
We cant use active status check for specific pads under calibration. This is common bit for all pads.
I'm not sure why this is a problem.
IIUC, the
start_calibration()should wait for theMIPI_CAL_STATUS_ACTIVEandfinish_calibration()should wait for MIPI_AUTO_CAL_DONE_CSIA/B.
As soon as START bit it set, FSM will set ACTIVE = 1
There is no added advantage of waiting for ACTIVE to be in start_calibration()
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 7 lines · Sowjanya Komatineni
Quoted 5 lines · Dmitry Osipenko
06.08.2020 19:13, Dmitry Osipenko пишет:
Quoted 4 lines
06.08.2020 18:59, Sowjanya Komatineni пишет:
..Quoted 2 lines
We cant use active status check for specific pads under calibration. This is common bit for all pads.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I'm not sure why this is a problem.
IIUC, the
start_calibration()should wait for theMIPI_CAL_STATUS_ACTIVEandfinish_calibration()should wait for MIPI_AUTO_CAL_DONE_CSIA/B.As soon as START bit it set, FSM will set ACTIVE = 1
There is no added advantage of waiting for ACTIVE to be in
start_calibration()
Also like I explained in other post of same discussion, ACTIVE we will be 1 even when other parallel pads are under calibration.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
In reply to Sowjanya Komatineni06.08.2020 18:59, Sowjanya Komatineni пишет:
...
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
Confirmed from HW designer, calibration FSM to finish takes worst case 72uS so by the time it gets to sensor stream it will be done its sequence and will be waiting for DONE bit.
So disabling MIPI CAL clock on sensor stream fails is safe.
72us is quite a lot of time, what will happen if LP-11 happens before FSM finished calibration?
Maybe the
finish_calibration()needs to split into two parts:
Quoted 8 lines
Quoted 2 lines
1. wait for
CAL_STATUS_ACTIVEbefore enabling sensor
2. wait forCAL_STATUS_DONEafter enabling sensorI don't think we need to split for active and done. Active will be 1 as long as other pads are in calibration as well.
We cant use active status check for specific pads under calibration. This is common bit for all pads.
Does hardware have a single FSM block shared by all pads or there is FSM per group of pads?
Quoted 7 lines
Unfortunately HW don't have separate status indicating when sequence is done to indicate its waiting for LP11.
To avoid all this, will remove
cancel_calibration()totally and use same finish calibration even in case of stream failure then.
What about to add 72us delay to the end of start_calibration() in order to ensure that FSM is finished before LP-11?
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 14 lines · Dmitry Osipenko
06.08.2020 18:59, Sowjanya Komatineni пишет:
...Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
Confirmed from HW designer, calibration FSM to finish takes worst case 72uS so by the time it gets to sensor stream it will be done its sequence and will be waiting for DONE bit.
So disabling MIPI CAL clock on sensor stream fails is safe.
72us is quite a lot of time, what will happen if LP-11 happens before FSM finished calibration?
Maybe the
finish_calibration()needs to split into two parts:1. wait for
CAL_STATUS_ACTIVEbefore enabling sensor
2. wait forCAL_STATUS_DONEafter enabling sensor
Quoted 7 lines
Quoted 5 lines
I don't think we need to split for active and done. Active will be 1 as long as other pads are in calibration as well.
We cant use active status check for specific pads under calibration. This is common bit for all pads.
Does hardware have a single FSM block shared by all pads or there is FSM per group of pads?
MIPI CAL status register has DONE bits for individual pads status and single ACTIVE bit.
ACTIVE bit set to 1 indicates auto calibration is active which is the case even when other pads (other CSI pads from other ports streaming in case of parallel stream) are under calibration. Also DSI is shared as well.
We do calibration for individual pads. So, we should not rely on ACTIVE bit.
MIPI driver checks for condition ACTIVE == 1 && DONE == 1 from the beginning.
But I think this also should be fixed as in case of parallel streams calibration can happen in parallel waiting for ACTIVE to be cleared makes all calibration callers to wait for longer than needed as ACTIVE is common for all pads.
Quoted 10 lines
Quoted 8 lines
Unfortunately HW don't have separate status indicating when sequence is done to indicate its waiting for LP11.
To avoid all this, will remove
cancel_calibration()totally and use same finish calibration even in case of stream failure then.What about to add 72us delay to the end of
start_calibration()in order to ensure that FSM is finished before LP-11?
Why we should add 72uS in start_calibration() when can use same finish_calibration() for both pass/fail cases?
Only timing loose we see is in case of failure we still wait for 250ms and as this is failing case I hope should be ok.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
06.08.2020 19:41, Sowjanya Komatineni пишет:
...
Quoted 9 lines
Quoted 2 lines
What about to add 72us delay to the end of
start_calibration()in order to ensure that FSM is finished before LP-11?Why we should add 72uS in
start_calibration()when can use samefinish_calibration()for both pass/fail cases?Only timing loose we see is in case of failure we still wait for 250ms and as this is failing case I hope should be ok.
You said that calibration settings are applied to pads on LP-11, but if LP-11 happens before FSM is finished, then what values will be applied if any?
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 7 lines · Dmitry Osipenko
06.08.2020 19:41, Sowjanya Komatineni пишет:
...Quoted 5 lines
Quoted 2 lines
What about to add 72us delay to the end of
start_calibration()in order to ensure that FSM is finished before LP-11?Why we should add 72uS in
start_calibration()when can use samefinish_calibration()for both pass/fail cases?
Quoted 6 lines
Quoted 3 lines
Only timing loose we see is in case of failure we still wait for 250ms and as this is failing case I hope should be ok.
You said that calibration settings are applied to pads on LP-11, but if LP-11 happens before FSM is finished, then what values will be applied if any?
No calibration logic will check for LP-11 only after finishing calibration sequence codes.
After that if it sees LP-11, it will apply results to pads and DONE bit will then be set to 1 indication pad results update.
Unfortunately like I said we don't have status indication for calibrating finished before waiting for LP-11.
ACTIVE bit is common for all PADS. If multiple 6 streams are happening in parallel, ACTIVE will be 1 as long as its calibrating any of the pads and its not for individual pads.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
06.08.2020 19:51, Sowjanya Komatineni пишет:
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines
What about to add 72us delay to the end of
start_calibration()in order to ensure that FSM is finished before LP-11?Why we should add 72uS in
start_calibration()when can use samefinish_calibration()for both pass/fail cases?Only timing loose we see is in case of failure we still wait for 250ms and as this is failing case I hope should be ok.
You said that calibration settings are applied to pads on LP-11, but if LP-11 happens before FSM is finished, then what values will be applied if any?
Quoted 5 lines
No calibration logic will check for LP-11 only after finishing calibration sequence codes.
After that if it sees LP-11, it will apply results to pads and DONE bit will then be set to 1 indication pad results update.
Are you sure that HW doesn't use level-triggered logic for LP-11 signal?
Quoted 2 lines
Unfortunately like I said we don't have status indication for calibrating finished before waiting for LP-11.
This is not a problem if hardware can cope with LP-11 happened at the time of calibration. If hardware can't cope with that, then somethings needs to be done about it.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
In reply to Sowjanya KomatineniQuoted 43 lines · Sowjanya Komatineni
Quoted 14 lines · Dmitry Osipenko
06.08.2020 18:59, Sowjanya Komatineni пишет:
...Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
Confirmed from HW designer, calibration FSM to finish takes worst case 72uS so by the time it gets to sensor stream it will be done its sequence and will be waiting for DONE bit.
So disabling MIPI CAL clock on sensor stream fails is safe.
72us is quite a lot of time, what will happen if LP-11 happens before FSM finished calibration?
Maybe the
finish_calibration()needs to split into two parts:1. wait for
CAL_STATUS_ACTIVEbefore enabling sensor
2. wait forCAL_STATUS_DONEafter enabling sensorQuoted 7 lines
Quoted 5 lines
I don't think we need to split for active and done. Active will be 1 as long as other pads are in calibration as well.
We cant use active status check for specific pads under calibration. This is common bit for all pads.
Does hardware have a single FSM block shared by all pads or there is FSM per group of pads?
MIPI CAL status register has DONE bits for individual pads status and single ACTIVE bit.
ACTIVE bit set to 1 indicates auto calibration is active which is the case even when other pads (other CSI pads from other ports streaming in case of parallel stream) are under calibration. Also DSI is shared as well.
We do calibration for individual pads. So, we should not rely on ACTIVE bit.
MIPI driver checks for condition ACTIVE == 1 && DONE == 1 from the beginning.
But I think this also should be fixed as in case of parallel streams calibration can happen in parallel waiting for ACTIVE to be cleared makes all calibration callers to wait for longer than needed as ACTIVE is common for all pads.
Quoted 8 lines
Quoted 8 lines
Unfortunately HW don't have separate status indicating when sequence is done to indicate its waiting for LP11.
To avoid all this, will remove
cancel_calibration()totally and use same finish calibration even in case of stream failure then.
Quoted 7 lines
Quoted 2 lines
What about to add 72us delay to the end of
start_calibration()in order to ensure that FSM is finished before LP-11?Why we should add 72uS in
start_calibration()when can use samefinish_calibration()for both pass/fail cases?Only timing loose we see is in case of failure we still wait for 250ms and as this is failing case I hope should be ok.
Also as we don't need cancel_calibration(), keeping tegra_mipi_wait() like earlier makes sense I believe as we are letting it finish going thru sequence.
So I think below are fixes,
1. Existing MIPI driver, tegra_mipi_wait() to not use status ACTIVE bit to be 0 and use only DONE bit to be 1 for wait condition as we are calibrating separately for individual pads and this ACTIVE bit is common for all pads where it will not be 0 in case of other parallel streams which may also be under calibration.
2. No need for separate cancel_calibration. So, probably earlier names tegra_mipi_calibrate() and tegra_mipi_wait() hols good as we are waiting for calibration sequence to finish irrespective of fail/pass.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
06.08.2020 20:12, Sowjanya Komatineni пишет:
Quoted 69 lines · Sowjanya Komatineni
Quoted 54 lines · Dmitry Osipenko
Quoted 15 lines
06.08.2020 18:59, Sowjanya Komatineni пишет:
...Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
Confirmed from HW designer, calibration FSM to finish takes worst case
72uS so by the time it gets to sensor stream it will be done its sequence and will be waiting for DONE bit.So disabling MIPI CAL clock on sensor stream fails is safe.
72us is quite a lot of time, what will happen if LP-11 happens before FSM finished calibration?
Maybe the
finish_calibration()needs to split into two parts:1. wait for
CAL_STATUS_ACTIVEbefore enabling sensor
2. wait forCAL_STATUS_DONEafter enabling sensorQuoted 7 lines
Quoted 5 lines
I don't think we need to split for active and done. Active will be 1 as long as other pads are in calibration as well.
We cant use active status check for specific pads under calibration. This is common bit for all pads.
Does hardware have a single FSM block shared by all pads or there is FSM per group of pads?
MIPI CAL status register has DONE bits for individual pads status and single ACTIVE bit.
ACTIVE bit set to 1 indicates auto calibration is active which is the case even when other pads (other CSI pads from other ports streaming in case of parallel stream) are under calibration. Also DSI is shared as well.
We do calibration for individual pads. So, we should not rely on ACTIVE bit.
MIPI driver checks for condition ACTIVE == 1 && DONE == 1 from the beginning.
But I think this also should be fixed as in case of parallel streams calibration can happen in parallel waiting for ACTIVE to be cleared makes all calibration callers to wait for longer than needed as ACTIVE is common for all pads.
Quoted 9 lines
Quoted 9 lines
Unfortunately HW don't have separate status indicating when sequence is done to indicate its waiting for LP11.
To avoid all this, will remove
cancel_calibration()totally and use same
finish calibration even in case of stream failure then.Quoted 9 lines
Quoted 2 lines
What about to add 72us delay to the end of
start_calibration()in order to ensure that FSM is finished before LP-11?Why we should add 72uS in
start_calibration()when can use samefinish_calibration()for both pass/fail cases?Only timing loose we see is in case of failure we still wait for 250ms and as this is failing case I hope should be ok.
Also as we don't need
cancel_calibration(), keepingtegra_mipi_wait()like earlier makes sense I believe as we are letting it finish going thru sequence.
Quoted 7 lines
So I think below are fixes,
1. Existing MIPI driver,
tegra_mipi_wait()to not use status ACTIVE bit to be 0 and use only DONE bit to be 1 for wait condition as we are calibrating separately for individual pads and this ACTIVE bit is common for all pads where it will not be 0 in case of other parallel streams which may also be under calibration.
Yes, looks like it's a mistake of the current MIPI driver that it polls the ACTIVE bit.
Quoted 3 lines
2. No need for separate
cancel_calibration. So, probably earlier namestegra_mipi_calibrate()andtegra_mipi_wait()hols good as we are waiting for calibration sequence to finish irrespective of fail/pass.
The new names reflect better what those functions actually do, IMO.
What about to make finish_calibration() to take an additional argument which corresponds to the awaited HW bits? For example if it's CSIA, then it could be:
tegra_mipi_finish_calibration(csi_chan->mipi, MIPI_CAL_CSIA);
Also, is it okay that DSI and CSI could change MIPI_CAL_CTRL after DSI or CSI already started calibration?
Looking at the current start_calibration(), I think the mutex should be kept locked and then finish_calibration() should unlock it.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 72 lines · Dmitry Osipenko
06.08.2020 20:12, Sowjanya Komatineni пишет:
Quoted 64 lines · Sowjanya Komatineni
Quoted 51 lines · Dmitry Osipenko
Quoted 15 lines
06.08.2020 18:59, Sowjanya Komatineni пишет:
...Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
Confirmed from HW designer, calibration FSM to finish takes worst case
72uS so by the time it gets to sensor stream it will be done its sequence and will be waiting for DONE bit.So disabling MIPI CAL clock on sensor stream fails is safe.
72us is quite a lot of time, what will happen if LP-11 happens before FSM finished calibration?
Maybe the
finish_calibration()needs to split into two parts:1. wait for
CAL_STATUS_ACTIVEbefore enabling sensor
2. wait forCAL_STATUS_DONEafter enabling sensorQuoted 7 lines
Quoted 5 lines
I don't think we need to split for active and done. Active will be 1 as long as other pads are in calibration as well.
We cant use active status check for specific pads under calibration. This is common bit for all pads.
Does hardware have a single FSM block shared by all pads or there is FSM per group of pads?
MIPI CAL status register has DONE bits for individual pads status and single ACTIVE bit.
ACTIVE bit set to 1 indicates auto calibration is active which is the case even when other pads (other CSI pads from other ports streaming in case of parallel stream) are under calibration. Also DSI is shared as well.
We do calibration for individual pads. So, we should not rely on ACTIVE bit.
MIPI driver checks for condition ACTIVE == 1 && DONE == 1 from the beginning.
But I think this also should be fixed as in case of parallel streams calibration can happen in parallel waiting for ACTIVE to be cleared makes all calibration callers to wait for longer than needed as ACTIVE is common for all pads.
Quoted 8 lines
Quoted 8 lines
Unfortunately HW don't have separate status indicating when sequence is done to indicate its waiting for LP11.
To avoid all this, will remove
cancel_calibration()totally and use same
finish calibration even in case of stream failure then.Quoted 8 lines
Quoted 2 lines
What about to add 72us delay to the end of
start_calibration()in order to ensure that FSM is finished before LP-11?Why we should add 72uS in
start_calibration()when can use samefinish_calibration()for both pass/fail cases?Only timing loose we see is in case of failure we still wait for 250ms and as this is failing case I hope should be ok.
Also as we don't need
cancel_calibration(), keepingtegra_mipi_wait()like earlier makes sense I believe as we are letting it finish going thru sequence.Quoted 7 lines
So I think below are fixes,
1. Existing MIPI driver,
tegra_mipi_wait()to not use status ACTIVE bit to be 0 and use only DONE bit to be 1 for wait condition as we are calibrating separately for individual pads and this ACTIVE bit is common for all pads where it will not be 0 in case of other parallel streams which may also be under calibration.
Quoted 7 lines
Yes, looks like it's a mistake of the current MIPI driver that it polls the ACTIVE bit.
Quoted 3 lines
2. No need for separate
cancel_calibration. So, probably earlier namestegra_mipi_calibrate()andtegra_mipi_wait()hols good as we are waiting for calibration sequence to finish irrespective of fail/pass.The new names reflect better what those functions actually do, IMO.
ok Will keep same names.
Quoted 6 lines
What about to make
finish_calibration()to take an additional argument which corresponds to the awaited HW bits? For example if it's CSIA, then it could be:tegra_mipi_finish_calibration(csi_chan->mipi, MIPI_CAL_CSIA);
MIPI device is separate for each stream so waiting for only those corresponding DONE bits happen currently and no need to pass argument.
Quoted 7 lines
Also, is it okay that DSI and CSI could change
MIPI_CAL_CTRLafter DSI or CSI already started calibration?Looking at the current
start_calibration(), I think the mutex should be kept locked and thenfinish_calibration()should unlock it.
Confirmed with HW designer.
ACTIVE is common bit for all pads where we see it 1 as long as all pads (DSI + all CSI Pads) are under calibration.
While MIPI CAL is doing calibration for certain pads, before issuing other start it has to wait for ACTIVE to be 0.
Earlier driver (before split) checks for ACTIVE to be 0 along with DONE bit to be 1 as it does both calibrate and wait in same API.
With the split, looks like we need below sequence to be safe.
1. tegra_mipi_start_calibration(): wait for ACTIVE to be 0 before issuing START and after issuing start wait for 72uS to let calibration code sequence finish so it will be ready to see LP-11 after that.
In case of parallel streams, call to start_calibration can happen when pads of other stream are under calibration.
2. tegra_mipi_finish_calibration(): check for DONE bit to be 1
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 81 lines · Sowjanya Komatineni
Quoted 72 lines · Dmitry Osipenko
06.08.2020 20:12, Sowjanya Komatineni пишет:
Quoted 64 lines · Sowjanya Komatineni
Quoted 51 lines · Dmitry Osipenko
Quoted 15 lines
06.08.2020 18:59, Sowjanya Komatineni пишет:
...Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
Confirmed from HW designer, calibration FSM to finish takes worst case
72uS so by the time it gets to sensor stream it will be done its sequence and will be waiting for DONE bit.So disabling MIPI CAL clock on sensor stream fails is safe.
72us is quite a lot of time, what will happen if LP-11 happens before FSM finished calibration?
Maybe the
finish_calibration()needs to split into two parts:1. wait for
CAL_STATUS_ACTIVEbefore enabling sensor
2. wait forCAL_STATUS_DONEafter enabling sensorQuoted 7 lines
Quoted 5 lines
I don't think we need to split for active and done. Active will be 1 as long as other pads are in calibration as well.
We cant use active status check for specific pads under calibration. This is common bit for all pads.
Does hardware have a single FSM block shared by all pads or there is FSM per group of pads?
MIPI CAL status register has DONE bits for individual pads status and single ACTIVE bit.
ACTIVE bit set to 1 indicates auto calibration is active which is the case even when other pads (other CSI pads from other ports streaming in case of parallel stream) are under calibration. Also DSI is shared as well.
We do calibration for individual pads. So, we should not rely on ACTIVE bit.
MIPI driver checks for condition ACTIVE == 1 && DONE == 1 from the beginning.
But I think this also should be fixed as in case of parallel streams calibration can happen in parallel waiting for ACTIVE to be cleared makes all calibration callers to wait for longer than needed as ACTIVE is common for all pads.
Quoted 8 lines
Quoted 8 lines
Unfortunately HW don't have separate status indicating when sequence is done to indicate its waiting for LP11.
To avoid all this, will remove
cancel_calibration()totally and use same
finish calibration even in case of stream failure then.Quoted 8 lines
Quoted 2 lines
What about to add 72us delay to the end of
start_calibration()in order to ensure that FSM is finished before LP-11?Why we should add 72uS in
start_calibration()when can use samefinish_calibration()for both pass/fail cases?Only timing loose we see is in case of failure we still wait for 250ms and as this is failing case I hope should be ok.
Also as we don't need
cancel_calibration(), keepingtegra_mipi_wait()like earlier makes sense I believe as we are letting it finish going thru sequence.Quoted 7 lines
So I think below are fixes,
1. Existing MIPI driver,
tegra_mipi_wait()to not use status ACTIVE bit to be 0 and use only DONE bit to be 1 for wait condition as we are calibrating separately for individual pads and this ACTIVE bit is common for all pads where it will not be 0 in case of other parallel streams which may also be under calibration.Quoted 7 lines
Yes, looks like it's a mistake of the current MIPI driver that it polls the ACTIVE bit.
Quoted 3 lines
2. No need for separate
cancel_calibration. So, probably earlier namestegra_mipi_calibrate()andtegra_mipi_wait()hols good as we are waiting for calibration sequence to finish irrespective of fail/pass.The new names reflect better what those functions actually do, IMO.
Quoted 15 lines
ok Will keep same names.
Quoted 6 lines
What about to make
finish_calibration()to take an additional argument which corresponds to the awaited HW bits? For example if it's CSIA, then it could be:
tegra_mipi_finish_calibration(csi_chan->mipi, MIPI_CAL_CSIA);MIPI device is separate for each stream so waiting for only those corresponding DONE bits happen currently and no need to pass argument.
Quoted 7 lines
Also, is it okay that DSI and CSI could change
MIPI_CAL_CTRLafter DSI or CSI already started calibration?Looking at the current
start_calibration(), I think the mutex should be kept locked and thenfinish_calibration()should unlock it.
Right mutex_unlock should happen at end of finish_calibration.
With keeping mutex locked in start, we dont have to check for active to be 0 to issue start as mutex will keep it locked and other pads calibration can only go thru when current one is done.
So instead of below sequence, its simpler to do this way?
start_calibration()
- mutex_lock
- wait for 72uS after start
finish_calibration()
- keep check for ACTIVE = 0 and DONE = 1
- mutex_unlock()
Quoted 20 lines
Confirmed with HW designer.
ACTIVE is common bit for all pads where we see it 1 as long as all pads (DSI + all CSI Pads) are under calibration.
While MIPI CAL is doing calibration for certain pads, before issuing other start it has to wait for ACTIVE to be 0.
Earlier driver (before split) checks for ACTIVE to be 0 along with DONE bit to be 1 as it does both calibrate and wait in same API.
With the split, looks like we need below sequence to be safe.
1.
tegra_mipi_start_calibration(): wait for ACTIVE to be 0 before issuing START and after issuing start wait for 72uS to let calibration code sequence finish so it will be ready to see LP-11 after that.In case of parallel streams, call to
start_calibrationcan happen when pads of other stream are under calibration.2.
tegra_mipi_finish_calibration(): check for DONE bit to be 1
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
06.08.2020 20:52, Sowjanya Komatineni пишет:
...
Quoted 10 lines
Right
mutex_unlockshould happen at end offinish_calibration.With keeping mutex locked in start, we dont have to check for active to be 0 to issue start as mutex will keep it locked and other pads calibration can only go thru when current one is done.
So instead of below sequence, its simpler to do this way?
start_calibration()
Quoted 7 lines
-
mutex_lock- wait for 72uS after start
finish_calibration()- keep check for ACTIVE = 0 and DONE = 1
I think only the DONE bits which correspond to the mipi_device->pads bitmask should be awaited.
Quoted 1 line
-
mutex_unlock()
Perhaps the start_calibration() also needs to be changed to not touch the MIPI_CAL_CONFIG bits of the unrelated pads?
Otherwise sounds good to me.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 14 lines · Dmitry Osipenko
06.08.2020 20:52, Sowjanya Komatineni пишет:
...Quoted 12 lines
Right
mutex_unlockshould happen at end offinish_calibration.With keeping mutex locked in start, we dont have to check for active to be 0 to issue start as mutex will keep it locked and other pads calibration can only go thru when current one is done.
So instead of below sequence, its simpler to do this way?
start_calibration()-
mutex_lock
Quoted 7 lines
Quoted 5 lines
- wait for 72uS after start
finish_calibration()- keep check for ACTIVE = 0 and DONE = 1
I think only the DONE bits which correspond to the
mipi_device->padsbitmask should be awaited.
As next START can't be triggered when auto cal is ACTIVE, we should keep this in finish.
As we do mutex_unlock only at end of finish, other pads calibrations dont go thru till the one in process is finished.
So in this case ACTIVE applies to current selected pads that are under calibration.
Quoted 4 lines
Quoted 2 lines
-
mutex_unlock()Perhaps the
start_calibration()also needs to be changed to not touch theMIPI_CAL_CONFIGbits of the unrelated pads?
Driver already takes care of programming corresponding pads config only.
Quoted 2 lines
Otherwise sounds good to me.
Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
06.08.2020 21:07, Sowjanya Komatineni пишет:
Quoted 24 lines · Dmitry Osipenko
Quoted 14 lines
06.08.2020 20:52, Sowjanya Komatineni пишет:
...Quoted 12 lines
Right
mutex_unlockshould happen at end offinish_calibration.With keeping mutex locked in start, we dont have to check for active to be 0 to issue start as mutex will keep it locked and other pads calibration can only go thru when current one is done.
So instead of below sequence, its simpler to do this way?
start_calibration()-
mutex_lockQuoted 7 lines
Quoted 5 lines
- wait for 72uS after start
finish_calibration()- keep check for ACTIVE = 0 and DONE = 1
I think only the DONE bits which correspond to the
mipi_device->padsbitmask should be awaited.
Quoted 8 lines
As next START can't be triggered when auto cal is ACTIVE, we should keep this in finish.
As we do
mutex_unlockonly at end of finish, other pads calibrations dont go thru till the one in process is finished.So in this case ACTIVE applies to current selected pads that are under calibration.
Should be better to check only the relevant bits in order to catch bugs, otherwise you may get a DONE status from the irrelevant pads.
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
-
mutex_unlock()Perhaps the
start_calibration()also needs to be changed to not touch theMIPI_CAL_CONFIGbits of the unrelated pads?Driver already takes care of programming corresponding pads config only.
It writes 0 to the config of the unrelated pads, which probably isn't nice if some pads use periodic auto-calibration.
https://elixir.bootlin.com/linux/v5.8/source/drivers/gpu/host1x/mipi.c#L350
Although looks like auto-calibration isn't supported by the current driver.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 26 lines · Dmitry Osipenko
06.08.2020 21:07, Sowjanya Komatineni пишет:
Quoted 25 lines · Dmitry Osipenko
Quoted 14 lines
06.08.2020 20:52, Sowjanya Komatineni пишет:
...Quoted 12 lines
Right
mutex_unlockshould happen at end offinish_calibration.With keeping mutex locked in start, we dont have to check for active to be 0 to issue start as mutex will keep it locked and other pads calibration can only go thru when current one is done.
So instead of below sequence, its simpler to do this way?
start_calibration()-
mutex_lockQuoted 7 lines
Quoted 5 lines
- wait for 72uS after start
finish_calibration()- keep check for ACTIVE = 0 and DONE = 1
I think only the DONE bits which correspond to the
mipi_device->padsbitmask should be awaited.As next START can't be triggered when auto cal is ACTIVE, we should keep this in finish.
Quoted 7 lines
Quoted 5 lines
As we do
mutex_unlockonly at end of finish, other pads calibrations dont go thru till the one in process is finished.So in this case ACTIVE applies to current selected pads that are under calibration.
Should be better to check only the relevant bits in order to catch bugs, otherwise you may get a DONE status from the irrelevant pads.
tegra_mipi_device is separate for DSI and CSI channels. mutex lock used during calibrate is device specific lock. So, it will not prevent other devices to hold till on going calibration is done unless we add wait for active bit before triggering start.
Currently we wait for active bit at end during calibration done check after start trigger. But when other devices go thru calibration in parallel as lock is device specific and not common lock for all devices it will trigger start but MIPI calibration logic ignore if previous calibration is still in progress.
Need to serialize calibration start requests from different devices based on ACTIVE bit.
Quoted 9 lines
Quoted 3 lines
Quoted 2 lines
Perhaps the
start_calibration()also needs to be changed to not touch theMIPI_CAL_CONFIGbits of the unrelated pads?Driver already takes care of programming corresponding pads config only.
It writes 0 to the config of the unrelated pads, which probably isn't nice if some pads use periodic auto-calibration.
https://elixir.bootlin.com/linux/v5.8/source/drivers/gpu/host1x/mipi.c#L350
Although looks like auto-calibration isn't supported by the current driver.
Yes we don't use auto-calibration.
Only common bit here is MIPI_CAL_CTRL start. All others are pad specific currently.
Sowjanya Komatineni
maintainerRe: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Quoted 33 lines · Sowjanya Komatineni
Quoted 31 lines · Dmitry Osipenko
06.08.2020 21:07, Sowjanya Komatineni пишет:
Quoted 30 lines · Dmitry Osipenko
Quoted 14 lines
06.08.2020 20:52, Sowjanya Komatineni пишет:
...Quoted 12 lines
Right
mutex_unlockshould happen at end offinish_calibration.With keeping mutex locked in start, we dont have to check for active to be 0 to issue start as mutex will keep it locked and other pads calibration can only go thru when current one is done.
So instead of below sequence, its simpler to do this way?
start_calibration()-
mutex_lockQuoted 7 lines
Quoted 5 lines
- wait for 72uS after start
finish_calibration()- keep check for ACTIVE = 0 and DONE = 1
I think only the DONE bits which correspond to the
mipi_device->padsbitmask should be awaited.As next START can't be triggered when auto cal is ACTIVE, we should keep this in finish.
As we do
mutex_unlockonly at end of finish, other pads calibrations dont go thru till the one in process is finished.So in this case ACTIVE applies to current selected pads that are under calibration.
Quoted 8 lines
Quoted 2 lines
Should be better to check only the relevant bits in order to catch bugs, otherwise you may get a DONE status from the irrelevant pads.
tegra_mipi_deviceis separate for DSI and CSI channels. mutex lock used during calibrate is device specific lock. So, it will not prevent other devices to hold till on going calibration is done unless we add wait for active bit before triggering start.Currently we wait for active bit at end during calibration done check after start trigger. But when other devices go thru calibration in parallel as lock is device specific and not common lock for all devices it will trigger start but MIPI calibration logic ignore if previous calibration is still in progress.
Need to serialize calibration start requests from different devices based on ACTIVE bit.
Sorry confused. MIPI driver is using common lock from tegra_mipi for all tegra_mipi_device
So should be ok as only one device start_calibration can happen at a time.
But its still good to check ACTIVE is cleared and to report as error if not as ACTIVE will be cleared once set of pads enabled for this calibration.
Eg: CSI port can be 4 lane and all 4 pads gets enabled at same time and with this ACTIVE should still be verified to be 0 to make sure all pads calibration is done
Quoted 16 lines
Quoted 11 lines
Quoted 4 lines
Quoted 3 lines
Perhaps the
start_calibration()also needs to be changed to not touch theMIPI_CAL_CONFIGbits of the unrelated pads?Driver already takes care of programming corresponding pads config only.
It writes 0 to the config of the unrelated pads, which probably isn't nice if some pads use periodic auto-calibration.
https://elixir.bootlin.com/linux/v5.8/source/drivers/gpu/host1x/mipi.c#L350
Although looks like auto-calibration isn't supported by the current driver.
Yes we don't use auto-calibration.
Only common bit here is
MIPI_CAL_CTRLstart. All others are pad specific currently.
Sowjanya Komatineni
maintainerPATCH v8 9/10 media: tegra-video: Add CSI MIPI pads calibration
In reply to Sowjanya KomatineniCSI MIPI pads need to be enabled and calibrated for capturing from the external sensor or transmitter.
MIPI CAL unit calibrates MIPI pads pull-up, pull-down and termination impedances. Calibration is done by co-work of MIPI BIAS pad and MIPI CAL control unit.
Triggering calibration start can happen any time after MIPI pads are enabled but calibration results will be latched and applied to MIPI pads by MIPI CAL unit only when the link is in LP11 state and then calibration status register gets updated.
This patch enables CSI MIPI pads and calibrates them during streaming.
Tegra CSI receiver is able to catch the very first clock transition. So, CSI receiver is always enabled prior to sensor streaming and trigger of calibration start is done during CSI subdev streaming and status of calibration is verified after sensor stream on.
--- drivers/staging/media/tegra-video/TODO | 1 - drivers/staging/media/tegra-video/csi.c | 61 +++++++++++++++++++++++++++++++-- drivers/staging/media/tegra-video/csi.h | 2 ++ drivers/staging/media/tegra-video/vi.c | 28 ++++++++++++--- 4 files changed, 84 insertions(+), 8 deletions(-)
drivers/staging/media/tegra-video/TODO +0 -1
@@ -1,5 +1,4 @@ TODO list -* Add Tegra CSI MIPI pads calibration. * Add MIPI clock Settle time computation based on the data rate. * Add support for Ganged mode. * Add RAW10 packed video format support to Tegra210 video formats.
drivers/staging/media/tegra-video/csi.c +58 -3
106 lines not on this page · raw message
drivers/staging/media/tegra-video/csi.h +2 -0
@@ -50,6 +50,7 @@ struct tegra_csi;* @framerate: active framerate for TPG * @h_blank: horizontal blanking for TPG active format * @v_blank: vertical blanking for TPG active format +* @mipi: mipi device for corresponding csi channel pads */ struct tegra_csi_channel {struct list_head list;
@@ -65,6 +66,7 @@ struct tegra_csi_channel {unsigned int framerate;unsigned int h_blank;unsigned int v_blank; +struct tegra_mipi_device *mipi; };/**
drivers/staging/media/tegra-video/vi.c +24 -4
@@ -191,6 +191,7 @@ tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan)static int tegra_channel_enable_stream (struct tegra_vi_channel *chan) {struct v4l2_subdev *csi_subdev, *src_subdev; +struct tegra_csi_channel *csi_chan;int ret;/*
@@ -206,14 +207,33 @@ static int tegra_channel_enable_stream(struct tegra_vi_channel *chan)if (IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG ))return 0 ; + csi_chan =v4l2_get_subdevdata (csi_subdev); +/* +* TRM has incorrectly documented to wait for done status from +* calibration logic after CSI interface power on. +* As per the design, calibration results are latched and applied +* to the pads only when the link is in LP11 state which will happen +* during the sensor stream-on. +* CSI subdev stream-on triggers start of MIPI pads calibration. +* Wait for calibration to finish here after sensor subdev stream-on +* and in case of sensor stream-on failure, cancel the calibration. +*/ src_subdev =tegra_channel_get_remote_source_subdev (chan); ret =v4l2_subdev_call (src_subdev, video, s_stream, true); -if (ret <0 && ret != -ENOIOCTLCMD ) { -v4l2_subdev_call (csi_subdev, video, s_stream, false); -return ret; - } +if (ret <0 && ret != -ENOIOCTLCMD ) + goto err_disable_csi_stream; + + ret =tegra_mipi_finish_calibration (csi_chan->mipi); +if (ret <0 ) +dev_warn (csi_chan->csi->dev, +"MIPI calibration failed: %d\n" , ret);return 0 ; + +err_disable_csi_stream: +tegra_mipi_cancel_calibration (csi_chan->mipi); +v4l2_subdev_call (csi_subdev, video, s_stream, false); +return ret; }static int tegra_channel_disable_stream (struct tegra_vi_channel *chan)
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerPATCH v8 10/10 media: tegra-video: Compute settle times based on the clock rate
In reply to Sowjanya KomatineniSettle time determines the number of cil clock cyles to wait after LP00 when moving from LP to HS.
This patch computes T-CLK-SETTLE and T-HS-SETTLE times based on cil clock rate and pixel rate from the sensor and programs them during streaming.
T-CLK-SETTLE time is the interval during which receiver will ignore any HS transitions on clock lane starting from the beginning of T-CLK-PREPARE.
T-HS-SETTLE time is the interval during which recevier will ignore any HS transitions on data lane starting from the beginning of T-HS-PREPARE.
--- drivers/staging/media/tegra-video/TODO | 1 - drivers/staging/media/tegra-video/csi.c | 55 ++++++++++++++++++++++++++++ drivers/staging/media/tegra-video/csi.h | 5 +++ drivers/staging/media/tegra-video/tegra210.c | 17 ++++++++- 4 files changed, 75 insertions(+), 3 deletions(-)
drivers/staging/media/tegra-video/TODO +0 -1
@@ -1,5 +1,4 @@ TODO list -* Add MIPI clock Settle time computation based on the data rate. * Add support for Ganged mode. * Add RAW10 packed video format support to Tegra210 video formats. * Add support for suspend and resume.
drivers/staging/media/tegra-video/csi.c +55 -0
67 lines not on this page · raw message
drivers/staging/media/tegra-video/csi.h +5 -0
@@ -51,6 +51,7 @@ struct tegra_csi;* @h_blank: horizontal blanking for TPG active format * @v_blank: vertical blanking for TPG active format * @mipi: mipi device for corresponding csi channel pads +* @pixel_rate: active pixel rate from the sensor on this channel */ struct tegra_csi_channel {struct list_head list;
@@ -67,6 +68,7 @@ struct tegra_csi_channel {unsigned int h_blank;unsigned int v_blank;struct tegra_mipi_device *mipi; +unsigned int pixel_rate; };/**
@@ -147,4 +149,7 @@ extern const struct tegra_csi_soc tegra210_csi_soc;#endif void tegra_csi_error_recover (struct v4l2_subdev *subdev); +void tegra_csi_calc_settle_time (struct tegra_csi_channel *csi_chan, +u8 *clk_settle_time, +u8 *ths_settle_time);#endif
drivers/staging/media/tegra-video/tegra210.c +15 -2
@@ -7,6 +7,7 @@* This source file contains Tegra210 supported video formats, * VI and CSI SoC specific data, operations and registers accessors. */ +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/clk/tegra.h> #include <linux/delay.h>
@@ -98,6 +99,8 @@#define BRICK_CLOCK_B_4X (0x2 << 16)#define TEGRA_CSI_CIL_PAD_CONFIG1 0x004#define TEGRA_CSI_CIL_PHY_CONTROL 0x008 +#define CLK_SETTLE_MASK GENMASK(13, 8) +#define THS_SETTLE_MASK GENMASK(5, 0)#define TEGRA_CSI_CIL_INTERRUPT_MASK 0x00c#define TEGRA_CSI_CIL_STATUS 0x010#define TEGRA_CSI_CILX_STATUS 0x014
@@ -770,8 +773,14 @@ static int tegra210_csi_start_streaming(struct tegra_csi_channel *csi_chan) {struct tegra_csi *csi = csi_chan->csi;unsigned int portno = csi_chan->csi_port_num; +u8 clk_settle_time =0 ; +u8 ths_settle_time =10 ;u32 val; +if (!csi_chan->pg_mode) +tegra_csi_calc_settle_time (csi_chan, &clk_settle_time, + &ths_settle_time); +csi_write (csi, portno,TEGRA_CSI_CLKEN_OVERRIDE ,0 );/* clean up status */
@@ -782,7 +791,9 @@ static int tegra210_csi_start_streaming(struct tegra_csi_channel *csi_chan)/* CIL PHY registers setup */ cil_write (csi, portno,TEGRA_CSI_CIL_PAD_CONFIG0 ,0x0 ); -cil_write (csi, portno,TEGRA_CSI_CIL_PHY_CONTROL ,0xa ); +cil_write (csi, portno,TEGRA_CSI_CIL_PHY_CONTROL , +FIELD_PREP (CLK_SETTLE_MASK , clk_settle_time) | +FIELD_PREP (THS_SETTLE_MASK , ths_settle_time));/* * The CSI unit provides for connection of up to six cameras in
@@ -801,7 +812,9 @@ static int tegra210_csi_start_streaming(struct tegra_csi_channel *csi_chan) BRICK_CLOCK_A_4X);cil_write (csi, portno +1 ,TEGRA_CSI_CIL_PAD_CONFIG0 ,0x0 );cil_write (csi, portno +1 ,TEGRA_CSI_CIL_INTERRUPT_MASK ,0x0 ); -cil_write (csi, portno +1 ,TEGRA_CSI_CIL_PHY_CONTROL ,0xa ); +cil_write (csi, portno +1 ,TEGRA_CSI_CIL_PHY_CONTROL , +FIELD_PREP (CLK_SETTLE_MASK , clk_settle_time) | +FIELD_PREP (THS_SETTLE_MASK , ths_settle_time));csi_write (csi, portno,TEGRA_CSI_PHY_CIL_COMMAND ,CSI_A_PHY_CIL_ENABLE |CSI_B_PHY_CIL_ENABLE ); }else {
Signature · 1 line
2.7.4