Support for Tegra video capture from external sensor
Subsystems (10)
Sowjanya Komatineni
maintainerv3 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 IMX219 camera sensor.
This series include,
VI I2C related fixes
- Camera sensor programming happens through VI I2C which is on host1x bus.
- These patches includes device tree and I2C driver fixes for VI I2C.
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.
Host1x driver updates
- Adds API to allow creating mipi device for specific device node.
- Splits MIPI pads calibrate start and waiting for calibration to be done.
Device tree updates
- Adds camera connector 2V8, 1V8, 1V2 regulator supplies to Jetson TX1 DT.
- Enabled VI and CSI support in Jetson Nano DT.
Delta between patch versions:
[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 (18):
dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and
power-domains
arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
i2c: tegra: Remove NULL pointer check before
clk_enable/disable/prepare/unprepare
i2c: tegra: Fix the error path in tegra_i2c_runtime_resume
i2c: tegra: Fix runtime resume to re-init VI I2C
i2c: tegra: Avoid tegra_i2c_init_dma() for Tegra210 vi i2c
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: Add support for external sensor capture
media: tegra-video: Add support for selection ioctl ops
gpu: host1x: mipi: Update tegra_mipi_request() to be node based
gpu: host1x: mipi: Use readl_relaxed_poll_timeout in tegra_mipi_wait
gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
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 ++- .../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt | 19 +- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 + drivers/gpu/drm/tegra/dsi.c | 9 +- drivers/gpu/host1x/mipi.c | 37 +- drivers/i2c/busses/i2c-tegra.c | 101 +-- drivers/staging/media/tegra-video/Kconfig | 7 + drivers/staging/media/tegra-video/csi.c | 247 ++++++- drivers/staging/media/tegra-video/csi.h | 8 + drivers/staging/media/tegra-video/tegra210.c | 25 +- drivers/staging/media/tegra-video/vi.c | 793 +++++++++++++++++++-- drivers/staging/media/tegra-video/vi.h | 25 +- drivers/staging/media/tegra-video/video.c | 23 +- include/linux/host1x.h | 4 +- 14 files changed, 1242 insertions(+), 154 deletions(-)
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerRFC PATCH v3 1/18 dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and power-domains
This patch documents missing clocks and power-domains of Tegra210 VI I2C.
--- .../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.txt +13 -6
@@ -35,12 +35,12 @@ Required properties: Due to above changes, Tegra114 I2C driver makes incompatible with previous hardware driver. Hence, tegra114 I2C controller is compatible with "nvidia,tegra114-i2c". - nvidia,tegra210-i2c-vi: Tegra210 has one I2C controller that is part of the - host1x domain and typically used for camera use-cases. This VI I2C - controller is mostly compatible with the programming model of the - regular I2C controllers with a few exceptions. The I2C registers start - at an offset of 0xc00 (instead of 0), registers are 16 bytes apart - (rather than 4) and the controller does not support slave mode. + nvidia,tegra210-i2c-vi: Tegra210 has one I2C controller that is on host1x bus + and is part of VE power domain and typically used for camera use-cases. + This VI I2C controller is mostly compatible with the programming model + of the regular I2C controllers with a few exceptions. The I2C registers + start at an offset of 0xc00 (instead of 0), registers are 16 bytes + apart (rather than 4) and the controller does not support slave mode. - reg: Should contain I2C controller registers physical address and length. - interrupts: Should contain I2C controller interrupts. - address-cells: Address cells for I2C device address.
@@ -53,10 +53,17 @@ Required properties: - fast-clk Tegra114: - div-clk + Tegra210: + - div-clk + - slow (only for nvidia,tegra210-i2c-vi compatible node) - resets: Must contain an entry for each entry in reset-names. See ../reset/reset.txt for details. - reset-names: Must include the following entries: - i2c +- power-domains: Only for nvidia,tegra210-i2c-vi compatible node and must + include venc powergate node as vi i2c is part of VE power domain. + tegra210-i2c-vi: + - pd_venc - dmas: Must contain an entry for each entry in clock-names. See ../dma/dma.txt for details. - dma-names: Must include the following entries:
Signature · 1 line
2.7.4
Thierry Reding
AppliedRe: [RFC PATCH v3 01/18] dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and power-domains
Quoted 7 lines · Sowjanya Komatineni
This patch documents missing clocks and power-domains of Tegra210 VI I2C.
Reviewed-by Rob Herring <[email protected]>Signed-off-by Sowjanya Komatineni <[email protected]>--- .../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
Applied, thanks.
Thierry
Sowjanya Komatineni
maintainerRFC PATCH v3 2/18 arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
In reply to Sowjanya KomatineniTegra210 VI I2C is in VE power domain and i2c-vi node should have power-domains property.
Current Tegra210 i2c-vi device node is missing both VI I2C clocks and power-domains property.
This patch adds them.
--- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +6 -0
@@ -375,6 +375,12 @@ compatible = "nvidia,tegra210-i2c-vi"; reg = <0x0 0x546c0000 0x0 0x00040000>; interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&tegra_car TEGRA210_CLK_VI_I2C>, + <&tegra_car TEGRA210_CLK_I2CSLOW>; + clock-names = "div-clk", "slow"; + resets = <&tegra_car TEGRA210_CLK_VI_I2C>; + reset-names = "i2c"; + power-domains = <&pd_venc>; status = "disabled"; }; };
Signature · 1 line
2.7.4
Thierry Reding
AppliedRe: [RFC PATCH v3 02/18] arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
Quoted 6 lines · Sowjanya Komatineni
Tegra210 VI I2C is in VE power domain and i2c-vi node should have power-domains property.
Current Tegra210 i2c-vi device node is missing both VI I2C clocks and power-domains property.
Quoted 6 lines
This patch adds them.
Signed-off-by Sowjanya Komatineni <[email protected]>--- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
Applied, thanks.
Thierry
Sowjanya Komatineni
maintainerRFC PATCH v3 3/18 i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
In reply to Sowjanya KomatineniTegra VI I2C is part of VE power domain and typically used for camera usecases.
VE power domain is not always on and is non-IRQ safe. So, IRQ safe device cannot be attached to a non-IRQ safe domain as it prevents powering off the PM domain and generic power domain driver will warn.
Current driver marks all I2C devices as IRQ safe and VI I2C device does not require IRQ safe as it will not be used for atomic transfers.
This patch has fix to make VI I2C as non-IRQ safe.
--- drivers/i2c/busses/i2c-tegra.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-tegra.c +9 -1
@@ -1750,7 +1750,15 @@ static int tegra_i2c_probe(struct platform_device *pdev) goto unprepare_slow_clk; } -pm_runtime_irq_safe (&pdev->dev); +/* +* VI I2C is in VE power domain which is not always on and not +* an IRQ safe. So, IRQ safe device can't be attached to a non-IRQ +* safe domain as it prevents powering off the PM domain. +* Also, VI I2C device don't need to use runtime IRQ safe as it will +* not be used for atomic transfers. +*/ +if (!i2c_dev->is_vi) +pm_runtime_irq_safe (&pdev->dev);pm_runtime_enable (&pdev->dev);if (!pm_runtime_enabled (&pdev->dev)) { ret =tegra_i2c_runtime_resume (&pdev->dev);
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerRFC PATCH v3 4/18 i2c: tegra: Remove NULL pointer check before clk_enable/disable/prepare/unprepare
In reply to Sowjanya Komatineniclk_enable, clk_disable, clk_prepare, and clk_unprepare APIs have implementation for checking clk pointer not NULL and clock consumers can safely call these APIs without NULL pointer check.
So, this patch cleans up Tegra i2c driver to remove explicit checks before these APIs.
--- drivers/i2c/busses/i2c-tegra.c | 64 +++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 41 deletions(-)
drivers/i2c/busses/i2c-tegra.c +23 -41
@@ -655,21 +655,17 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)if (ret)return ret; -if (!i2c_dev->hw->has_single_clk_source) { - ret =clk_enable (i2c_dev->fast_clk); -if (ret <0 ) { -dev_err (i2c_dev->dev, -"Enabling fast clk failed, err %d\n" , ret); -return ret; - } + ret =clk_enable (i2c_dev->fast_clk); +if (ret <0 ) { +dev_err (i2c_dev->dev, +"Enabling fast clk failed, err %d\n" , ret); +return ret; } -if (i2c_dev->slow_clk) { - ret =clk_enable (i2c_dev->slow_clk); -if (ret <0 ) { -dev_err (dev,"failed to enable slow clock: %d\n" , ret); -return ret; - } + ret =clk_enable (i2c_dev->slow_clk); +if (ret <0 ) { +dev_err (dev,"failed to enable slow clock: %d\n" , ret); +return ret; } ret =clk_enable (i2c_dev->div_clk);
@@ -688,12 +684,8 @@ static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev)struct tegra_i2c_dev *i2c_dev =dev_get_drvdata (dev);clk_disable (i2c_dev->div_clk); - -if (i2c_dev->slow_clk) -clk_disable (i2c_dev->slow_clk); - -if (!i2c_dev->hw->has_single_clk_source) -clk_disable (i2c_dev->fast_clk); +clk_disable (i2c_dev->slow_clk); +clk_disable (i2c_dev->fast_clk);return pinctrl_pm_select_idle_state (i2c_dev->dev); }
@@ -1716,20 +1708,16 @@ static int tegra_i2c_probe(struct platform_device *pdev)platform_set_drvdata (pdev, i2c_dev); -if (!i2c_dev->hw->has_single_clk_source) { - ret =clk_prepare (i2c_dev->fast_clk); -if (ret <0 ) { -dev_err (i2c_dev->dev,"Clock prepare failed %d\n" , ret); -return ret; - } + ret =clk_prepare (i2c_dev->fast_clk); +if (ret <0 ) { +dev_err (i2c_dev->dev,"Clock prepare failed %d\n" , ret); +return ret; } -if (i2c_dev->slow_clk) { - ret =clk_prepare (i2c_dev->slow_clk); -if (ret <0 ) { -dev_err (dev,"failed to prepare slow clock: %d\n" , ret); - goto unprepare_fast_clk; - } + ret =clk_prepare (i2c_dev->slow_clk); +if (ret <0 ) { +dev_err (dev,"failed to prepare slow clock: %d\n" , ret); + goto unprepare_fast_clk; } if (i2c_dev->bus_clk_rate > I2C_MAX_FAST_MODE_FREQ &&
@@ -1843,12 +1831,10 @@ static int tegra_i2c_probe(struct platform_device *pdev)clk_unprepare (i2c_dev->div_clk); unprepare_slow_clk: -if (i2c_dev->is_vi) -clk_unprepare (i2c_dev->slow_clk); +clk_unprepare (i2c_dev->slow_clk); unprepare_fast_clk: -if (!i2c_dev->hw->has_single_clk_source) -clk_unprepare (i2c_dev->fast_clk); +clk_unprepare (i2c_dev->fast_clk);return ret; }
@@ -1867,12 +1853,8 @@ static int tegra_i2c_remove(struct platform_device *pdev)tegra_i2c_runtime_suspend (&pdev->dev);clk_unprepare (i2c_dev->div_clk); - -if (i2c_dev->slow_clk) -clk_unprepare (i2c_dev->slow_clk); - -if (!i2c_dev->hw->has_single_clk_source) -clk_unprepare (i2c_dev->fast_clk); +clk_unprepare (i2c_dev->slow_clk); +clk_unprepare (i2c_dev->fast_clk);tegra_i2c_release_dma (i2c_dev);return 0 ;
Signature · 1 line
2.7.4
Re: [RFC PATCH v3 04/18] i2c: tegra: Remove NULL pointer check before clk_enable/disable/prepare/unprepare
15.07.2020 07:20, Sowjanya Komatineni пишет:
Quoted 9 lines
clk_enable,clk_disable,clk_prepare, andclk_unprepareAPIs have implementation for checking clk pointer not NULL and clock consumers can safely call these APIs without NULL pointer check.So, this patch cleans up Tegra i2c driver to remove explicit checks before these APIs.
Signed-off-by Sowjanya Komatineni <[email protected]>---
Thanks!
Sowjanya Komatineni
maintainerRFC PATCH v3 5/18 i2c: tegra: Fix the error path in tegra_i2c_runtime_resume
In reply to Sowjanya Komatinenitegra_i2c_runtime_resume does not disable prior enabled clocks properly.
This patch fixes it.
--- drivers/i2c/busses/i2c-tegra.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-tegra.c +8 -3
@@ -665,18 +665,23 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) ret =clk_enable (i2c_dev->slow_clk);if (ret <0 ) {dev_err (dev,"failed to enable slow clock: %d\n" , ret); -return ret; + goto disable_fast_clk; } ret =clk_enable (i2c_dev->div_clk);if (ret <0 ) {dev_err (i2c_dev->dev,"Enabling div clk failed, err %d\n" , ret); -clk_disable (i2c_dev->fast_clk); -return ret; + goto disable_slow_clk; }return 0 ; + +disable_slow_clk: +clk_disable (i2c_dev->slow_clk); +disable_fast_clk: +clk_disable (i2c_dev->fast_clk); +return ret; }static int __maybe_unused tegra_i2c_runtime_suspend (struct device *dev)
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerRFC PATCH v3 6/18 i2c: tegra: Fix runtime resume to re-init VI I2C
In reply to Sowjanya KomatineniVI I2C is on host1x bus and is part of VE power domain.
During suspend/resume VE power domain goes through power off/on.
So, controller reset followed by i2c re-initialization is required after the domain power up.
This patch fixes it.
--- drivers/i2c/busses/i2c-tegra.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/i2c/busses/i2c-tegra.c +16 -0
@@ -293,6 +293,8 @@ struct tegra_i2c_dev {bool is_curr_atomic_xfer; }; +static int tegra_i2c_init (struct tegra_i2c_dev *i2c_dev,bool clk_reinit); +static void dvc_writel (struct tegra_i2c_dev *i2c_dev,u32 val,unsigned long reg) {
@@ -675,8 +677,22 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) goto disable_slow_clk; } +/* +* VI I2C device is attached to VE power domain which goes through +* power ON/OFF during PM runtime resume/suspend. So, controller +* should go through reset and need to re-initialize after power +* domain ON. +*/ +if (i2c_dev->is_vi) { + ret =tegra_i2c_init (i2c_dev, true); +if (ret) + goto disable_div_clk; + } +return 0 ; +disable_div_clk: +clk_disable (i2c_dev->div_clk); disable_slow_clk:clk_disable (i2c_dev->slow_clk); disable_fast_clk:
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerRFC PATCH v3 7/18 i2c: tegra: Avoid tegra_i2c_init_dma() for Tegra210 vi i2c
In reply to Sowjanya KomatineniVI I2C is on host1x bus so APB DMA can't be used for Tegra210 VI I2C and there are no tx and rx dma channels for VI I2C.
So, avoid attempt of requesting DMA channels.
--- drivers/i2c/busses/i2c-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-tegra.c +1 -1
@@ -421,7 +421,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)dma_addr_t dma_phys;int err; -if (!i2c_dev->hw->has_apb_dma) +if (!i2c_dev->hw->has_apb_dma || i2c_dev->is_vi)return 0 ;if (!IS_ENABLED (CONFIG_TEGRA20_APB_DMA )) {
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerRFC PATCH v3 8/18 media: tegra-video: Fix channel format alignment
In reply to Sowjanya KomatineniPixel 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
maintainerRFC PATCH v3 9/18 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);
@@ -914,10 +916,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
maintainerRFC PATCH v3 10/18 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
maintainerRFC PATCH v3 11/18 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
Re: [RFC PATCH v3 11/18] dt-bindings: tegra: Update VI and CSI bindings with port info
Quoted 8 lines · Sowjanya Komatineni
Update VI and CSI bindings to add port and endpoint nodes as per media video-interfaces DT binding document.
Signed-off-by Sowjanya Komatineni <[email protected]>--- .../display/tegra/nvidia,tegra20-host1x.txt | 92 +++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-)
Sowjanya Komatineni
maintainerRFC PATCH v3 12/18 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/csi.c | 130 +++++- drivers/staging/media/tegra-video/csi.h | 1 + drivers/staging/media/tegra-video/tegra210.c | 2 +- drivers/staging/media/tegra-video/vi.c | 648 +++++++++++++++++++++++++-- drivers/staging/media/tegra-video/vi.h | 25 +- 6 files changed, 749 insertions(+), 58 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/csi.c +111 -19
174 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 +611 -37
806 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
Sowjanya Komatineni
maintainerRFC PATCH v3 13/18 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
@@ -437,6 +437,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);
@@ -462,6 +469,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;
@@ -551,6 +576,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) {
@@ -608,6 +712,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
maintainerRFC PATCH v3 14/18 gpu: host1x: mipi: Update tegra_mipi_request() to be node based
In reply to Sowjanya KomatineniTegra CSI driver need a separate MIPI device for each channel as calibration of corresponding MIPI pads for each channel should happen independently.
So, this patch updates tegra_mipi_request() API to add a device_node pointer argument to allow creating mipi device for specific device node rather than a device.
--- drivers/gpu/drm/tegra/dsi.c | 2 +- drivers/gpu/host1x/mipi.c | 4 ++-- include/linux/host1x.h | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/tegra/dsi.c +1 -1
@@ -1618,7 +1618,7 @@ static int tegra_dsi_probe(struct platform_device *pdev)if (IS_ERR (dsi->regs))return PTR_ERR (dsi->regs); - dsi->mipi =tegra_mipi_request (&pdev->dev); + dsi->mipi =tegra_mipi_request (&pdev->dev, pdev->dev.of_node);if (IS_ERR (dsi->mipi))return PTR_ERR (dsi->mipi);
drivers/gpu/host1x/mipi.c +2 -2
@@ -206,9 +206,9 @@ static int tegra_mipi_power_down(struct tegra_mipi *mipi)return 0 ; } -struct tegra_mipi_device *tegra_mipi_request (struct device *device) +struct tegra_mipi_device *tegra_mipi_request (struct device *device, +struct device_node *np) { -struct device_node *np = device->of_node;struct tegra_mipi_device *dev;struct of_phandle_args args;int err;
include/linux/host1x.h +2 -1
@@ -328,7 +328,8 @@ int host1x_client_resume(struct host1x_client *client);struct tegra_mipi_device ; -struct tegra_mipi_device *tegra_mipi_request (struct device *device); +struct tegra_mipi_device *tegra_mipi_request (struct device *device, +struct device_node *np);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);
Signature · 1 line
2.7.4
Re: [RFC PATCH v3 14/18] gpu: host1x: mipi: Update tegra_mipi_request() to be node based
15.07.2020 07:20, Sowjanya Komatineni пишет:
Quoted 10 lines
Tegra CSI driver need a separate MIPI device for each channel as calibration of corresponding MIPI pads for each channel should happen independently.
So, this patch updates
tegra_mipi_request()API to add adevice_nodepointer argument to allow creating mipi device for specific device node rather than a device.Signed-off-by Sowjanya Komatineni <[email protected]>---
Thanks!
Sowjanya Komatineni
maintainerRFC PATCH v3 15/18 gpu: host1x: mipi: Use readl_relaxed_poll_timeout in tegra_mipi_wait
In reply to Sowjanya KomatineniUse readl_relaxed_poll_timeout() in tegra_mipi_wait() to simplify the code.
--- drivers/gpu/host1x/mipi.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/gpu/host1x/mipi.c +8 -12
@@ -21,9 +21,9 @@*/ #include <linux/clk.h> -#include <linux/delay.h> #include <linux/host1x.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/slab.h>
@@ -295,19 +295,15 @@ EXPORT_SYMBOL(tegra_mipi_disable);static int tegra_mipi_wait (struct tegra_mipi *mipi) { -unsigned long timeout = jiffies +msecs_to_jiffies (250 ); +void __iomem *status_reg = mipi->regs + (MIPI_CAL_STATUS <<2 );u32 value; +int err; -while (time_before (jiffies, timeout)) { - value =tegra_mipi_readl (mipi,MIPI_CAL_STATUS ); -if ((value &MIPI_CAL_STATUS_ACTIVE ) ==0 && - (value &MIPI_CAL_STATUS_DONE ) !=0 ) -return 0 ; - -usleep_range (10 ,50 ); - } - -return -ETIMEDOUT ; + err =readl_relaxed_poll_timeout (status_reg, value, + !(value &MIPI_CAL_STATUS_ACTIVE ) && + (value &MIPI_CAL_STATUS_DONE ),50 , +250000 ); +return err; }int tegra_mipi_calibrate (struct tegra_mipi_device *device)
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerRFC PATCH v3 16/18 gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
In reply to Sowjanya KomatineniSW can trigger MIPI pads calibration any time after power on but calibration results will be latched and applied to the pads by MIPI CAL unit only when the link is in LP-11 state and then status register will be updated.
For CSI, trigger of pads calibration happen during CSI stream enable where CSI receiver is kept ready prior to sensor or CSI transmitter stream start.
So, pads may not be in LP-11 at this time and waiting for the calibration to be done immediate after calibration start will result in timeout.
This patch splits tegra_mipi_calibrate() and tegra_mipi_wait() so triggering for calibration and waiting for it to complete can happen at different stages.
--- drivers/gpu/drm/tegra/dsi.c | 7 ++++++- drivers/gpu/host1x/mipi.c | 17 +++++++++++++---- include/linux/host1x.h | 1 + 3 files changed, 20 insertions(+), 5 deletions(-)
drivers/gpu/drm/tegra/dsi.c +6 -1
@@ -670,6 +670,7 @@ static int tegra_dsi_pad_enable(struct tegra_dsi *dsi)static int tegra_dsi_pad_calibrate (struct tegra_dsi *dsi) {u32 value; +int ret;/* * XXX Is this still needed? The module reset is deasserted right
@@ -693,7 +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 ); -return tegra_mipi_calibrate (dsi->mipi); + ret =tegra_mipi_calibrate (dsi->mipi); +if (ret <0 ) +return ret; + +return tegra_mipi_wait (dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk,
drivers/gpu/host1x/mipi.c +13 -4
@@ -293,18 +293,29 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) }EXPORT_SYMBOL (tegra_mipi_disable); -static int tegra_mipi_wait (struct tegra_mipi *mipi) +int tegra_mipi_wait (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, !(value &MIPI_CAL_STATUS_ACTIVE ) && (value &MIPI_CAL_STATUS_DONE ),50 ,250000 ); +mutex_unlock (&device->mipi->lock); +clk_disable (device->mipi->clk); +return err; } +EXPORT_SYMBOL (tegra_mipi_wait);int tegra_mipi_calibrate (struct tegra_mipi_device *device) {
@@ -370,12 +381,10 @@ int tegra_mipi_calibrate(struct tegra_mipi_device *device) value |=MIPI_CAL_CTRL_START ;tegra_mipi_writel (device->mipi, value,MIPI_CAL_CTRL ); - err =tegra_mipi_wait (device->mipi); -mutex_unlock (&device->mipi->lock);clk_disable (device->mipi->clk); -return err; +return 0 ; }EXPORT_SYMBOL (tegra_mipi_calibrate);
include/linux/host1x.h +1 -0
@@ -334,5 +334,6 @@ 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);#endif
Signature · 1 line
2.7.4
Dmitry Osipenko
reviewerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
15.07.2020 07:20, Sowjanya Komatineni пишет:
Quoted 19 lines
SW can trigger MIPI pads calibration any time after power on but calibration results will be latched and applied to the pads by MIPI CAL unit only when the link is in LP-11 state and then status register will be updated.
For CSI, trigger of pads calibration happen during CSI stream enable where CSI receiver is kept ready prior to sensor or CSI transmitter stream start.
So, pads may not be in LP-11 at this time and waiting for the calibration to be done immediate after calibration start will result in timeout.
This patch splits
tegra_mipi_calibrate()andtegra_mipi_wait()so triggering for calibration and waiting for it to complete can happen at different stages.Signed-off-by Sowjanya Komatineni <[email protected]>---
...
drivers/gpu/host1x/mipi.c int tegra_mipi_calibrate(struct tegra_mipi_device *device) · line 373
Quoted 7 lines
int
tegra_mipi_calibrate(struct tegra_mipi_device *device){drivers/gpu/host1x/mipi.c +0
-1@@ -370,12 +381,10 @@ int tegra_mipi_calibrate(struct tegra_mipi_device *device) value |=MIPI_CAL_CTRL_START ;tegra_mipi_writel (device->mipi, value,MIPI_CAL_CTRL ); - err =tegra_mipi_wait (device->mipi);
Doesn't MIPI clock need to be enabled during of the calibration process?
Quoted 7 lines
drivers/gpu/host1x/mipi.c +1
-1mutex_unlock (&device->mipi->lock);clk_disable (device->mipi->clk); -return err; +return 0 ; }EXPORT_SYMBOL (tegra_mipi_calibrate);
Sowjanya Komatineni
maintainerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
Quoted 21 lines · Dmitry Osipenko
15.07.2020 07:20, Sowjanya Komatineni пишет:
Quoted 19 lines
SW can trigger MIPI pads calibration any time after power on but calibration results will be latched and applied to the pads by MIPI CAL unit only when the link is in LP-11 state and then status register will be updated.
For CSI, trigger of pads calibration happen during CSI stream enable where CSI receiver is kept ready prior to sensor or CSI transmitter stream start.
So, pads may not be in LP-11 at this time and waiting for the calibration to be done immediate after calibration start will result in timeout.
This patch splits
tegra_mipi_calibrate()andtegra_mipi_wait()so triggering for calibration and waiting for it to complete can happen at different stages.Signed-off-by Sowjanya Komatineni <[email protected]>---
...
Quoted 8 lines
drivers/gpu/host1x/mipi.c int tegra_mipi_calibrate(struct tegra_mipi_device *device) · line 373
Quoted 7 lines
int tegra_mipi_calibrate(struct tegra_mipi_device *device) {drivers/gpu/host1x/mipi.c +0
-1@@ -370,12 +381,10 @@ int tegra_mipi_calibrate(struct tegra_mipi_device *device) value |=MIPI_CAL_CTRL_START ;tegra_mipi_writel (device->mipi, value,MIPI_CAL_CTRL ); - err =tegra_mipi_wait (device->mipi);Doesn't MIPI clock need to be enabled during of the calibration process?
MIPI clock is already enabled in tegra_mipi_calibrate
Quoted 8 lines
Quoted 8 lines
drivers/gpu/host1x/mipi.c +1
-1mutex_unlock (&device->mipi->lock);clk_disable (device->mipi->clk); -return err; +return 0 ; }EXPORT_SYMBOL (tegra_mipi_calibrate);
Dmitry Osipenko
reviewerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
17.07.2020 00:09, Sowjanya Komatineni пишет:
Quoted 31 lines · Dmitry Osipenko
Quoted 21 lines
15.07.2020 07:20, Sowjanya Komatineni пишет:
Quoted 19 lines
SW can trigger MIPI pads calibration any time after power on but calibration results will be latched and applied to the pads by MIPI CAL unit only when the link is in LP-11 state and then status register will be updated.
For CSI, trigger of pads calibration happen during CSI stream enable where CSI receiver is kept ready prior to sensor or CSI transmitter stream start.
So, pads may not be in LP-11 at this time and waiting for the calibration to be done immediate after calibration start will result in timeout.
This patch splits
tegra_mipi_calibrate()andtegra_mipi_wait()so triggering for calibration and waiting for it to complete can happen at different stages.Signed-off-by Sowjanya Komatineni <[email protected]>---
...
Quoted 8 lines
drivers/gpu/host1x/mipi.c int tegra_mipi_calibrate(struct · line 384
Quoted 7 lines
int
tegra_mipi_calibrate(struct tegra_mipi_device *device){drivers/gpu/host1x/mipi.c +0
-0@@ -370,12 +381,10 @@ int tegra_mipi_calibrate(struct tegra_mipi_device *device) value |= MIPI_CAL_CTRL_START; tegra_mipi_writel(device->mipi, value, MIPI_CAL_CTRL); - err = tegra_mipi_wait(device->mipi);Doesn't MIPI clock need to be enabled during of the calibration process?
Quoted 4 lines
MIPI clock is already enabled in
tegra_mipi_calibrateQuoted 3 lines
Quoted 3 lines
drivers/gpu/host1x/mipi.c +0
-0mutex_unlock(&device->mipi->lock); clk_disable(device->mipi->clk);
What keeps MIPI clock enabled after completion of the tegra_mipi_calibrate() invocation?
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/host1x/mipi.c +1
-0- return err; + return 0; } EXPORT_SYMBOL(tegra_mipi_calibrate);
Sowjanya Komatineni
maintainerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
Quoted 31 lines · Dmitry Osipenko
17.07.2020 00:09, Sowjanya Komatineni пишет:
Quoted 30 lines · Dmitry Osipenko
Quoted 29 lines
15.07.2020 07:20, Sowjanya Komatineni пишет:
Quoted 19 lines
SW can trigger MIPI pads calibration any time after power on but calibration results will be latched and applied to the pads by MIPI CAL unit only when the link is in LP-11 state and then status register will be updated.
For CSI, trigger of pads calibration happen during CSI stream enable where CSI receiver is kept ready prior to sensor or CSI transmitter stream start.
So, pads may not be in LP-11 at this time and waiting for the calibration to be done immediate after calibration start will result in timeout.
This patch splits
tegra_mipi_calibrate()andtegra_mipi_wait()so triggering for calibration and waiting for it to complete can happen at different stages.Signed-off-by Sowjanya Komatineni <[email protected]>---
...
drivers/gpu/host1x/mipi.c int tegra_mipi_calibrate(struct · line 384
Quoted 7 lines
int
tegra_mipi_calibrate(struct tegra_mipi_device *device){drivers/gpu/host1x/mipi.c +0
-0@@ -370,12 +381,10 @@ int tegra_mipi_calibrate(struct tegra_mipi_device *device) value |= MIPI_CAL_CTRL_START; tegra_mipi_writel(device->mipi, value, MIPI_CAL_CTRL); - err = tegra_mipi_wait(device->mipi);Doesn't MIPI clock need to be enabled during of the calibration process?
Quoted 5 lines
Quoted 3 lines
MIPI clock is already enabled in
tegra_mipi_calibrateQuoted 2 lines
Quoted 2 lines
drivers/gpu/host1x/mipi.c +0
-0mutex_unlock(&device->mipi->lock); clk_disable(device->mipi->clk);What keeps MIPI clock enabled after completion of the
tegra_mipi_calibrate()invocation?
MIPI clock is disabled at end of tegra_mipi_calibrate and is re-enabled during tegra_mipi_wait.
I think I should fix this to keep the clock enabled till calibration results are latched.
All consumers of tegra_mipi_calibrate() will call tegra_mipi_wait().
So will remove clk_disable mipi clk at end of tegra_mipi_calibrate() and clk_enable mipi_clk at beginning of tegra_mipi_wait()
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/host1x/mipi.c +1
-0- return err; + return 0; } EXPORT_SYMBOL(tegra_mipi_calibrate);
Dmitry Osipenko
reviewerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
17.07.2020 01:49, Sowjanya Komatineni пишет:
Quoted 6 lines
Quoted 2 lines
What keeps MIPI clock enabled after completion of the
tegra_mipi_calibrate()invocation?MIPI clock is disabled at end of
tegra_mipi_calibrateand is re-enabled duringtegra_mipi_wait.
Quoted 7 lines
I think I should fix this to keep the clock enabled till calibration results are latched.
All consumers of
tegra_mipi_calibrate()will calltegra_mipi_wait().So will remove
clk_disablemipi clk at end oftegra_mipi_calibrate()andclk_enablemipi_clkat beginning oftegra_mipi_wait()
Isn't it possible to perform the calibration after enabling CSI and before of starting the sensor streaming?
Sowjanya Komatineni
maintainerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
Quoted 9 lines · Dmitry Osipenko
17.07.2020 01:49, Sowjanya Komatineni пишет:
Quoted 8 lines
Quoted 2 lines
What keeps MIPI clock enabled after completion of the
tegra_mipi_calibrate()invocation?MIPI clock is disabled at end of
tegra_mipi_calibrateand is re-enabled duringtegra_mipi_wait.I think I should fix this to keep the clock enabled till calibration results are latched.
Quoted 6 lines
Quoted 4 lines
All consumers of
tegra_mipi_calibrate()will calltegra_mipi_wait().So will remove
clk_disablemipi clk at end oftegra_mipi_calibrate()andclk_enablemipi_clkat beginning oftegra_mipi_wait()Isn't it possible to perform the calibration after enabling CSI and before of starting the sensor streaming?
Currently this is what I am doing. Triggering calibration start during CSI receiver being ready and then sensor streaming will happen where internal MIPI CAL detects for LP -> HS transition and applies results to pads. So checking for calibration results after sensor stream is enabled
Sowjanya Komatineni
maintainerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
Quoted 11 lines · Sowjanya Komatineni
Quoted 9 lines · Dmitry Osipenko
17.07.2020 01:49, Sowjanya Komatineni пишет:
Quoted 8 lines
Quoted 2 lines
What keeps MIPI clock enabled after completion of the
tegra_mipi_calibrate()invocation?MIPI clock is disabled at end of
tegra_mipi_calibrateand is re-enabled duringtegra_mipi_wait.I think I should fix this to keep the clock enabled till calibration results are latched.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
All consumers of
tegra_mipi_calibrate()will calltegra_mipi_wait().So will remove
clk_disablemipi clk at end oftegra_mipi_calibrate()andclk_enablemipi_clkat beginning oftegra_mipi_wait()Isn't it possible to perform the calibration after enabling CSI and before of starting the sensor streaming?
Currently this is what I am doing. Triggering calibration start during CSI receiver being ready and then sensor streaming will happen where internal MIPI CAL detects for LP -> HS transition and applies results to pads. So checking for calibration results after sensor stream is enabled
1. Calling tegra_mipi_calibrate() during CSI streaming where CSI pads are enabled and receiver is kept ready
2. Start Sensor stream
3. Calling tegra_mipi_wait() to check for MIPI Cal status.
So as mipi cal clk need to be kept enabled till 3rd step, we can enable clock during tegra_mipi_calibrate() and leave it enabled and disable it in tegra_mipi_wait after status check.
Dmitry Osipenko
reviewerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
17.07.2020 02:09, Sowjanya Komatineni пишет:
Quoted 29 lines · Sowjanya Komatineni
Quoted 16 lines · Dmitry Osipenko
Quoted 14 lines
17.07.2020 01:49, Sowjanya Komatineni пишет:
Quoted 13 lines
Quoted 2 lines
What keeps MIPI clock enabled after completion of the
tegra_mipi_calibrate()invocation?MIPI clock is disabled at end of
tegra_mipi_calibrateand is re-enabled duringtegra_mipi_wait.I think I should fix this to keep the clock enabled till calibration results are latched.
All consumers of
tegra_mipi_calibrate()will calltegra_mipi_wait().So will remove
clk_disablemipi clk at end oftegra_mipi_calibrate()andclk_enablemipi_clkat beginning oftegra_mipi_wait()Quoted 7 lines
Quoted 2 lines
Isn't it possible to perform the calibration after enabling CSI and before of starting the sensor streaming?
Currently this is what I am doing. Triggering calibration start during CSI receiver being ready and then sensor streaming will happen where internal MIPI CAL detects for LP -> HS transition and applies results to pads. So checking for calibration results after sensor stream is enabled
1. Calling
tegra_mipi_calibrate()during CSI streaming where CSI pads are enabled and receiver is kept ready
Quoted 7 lines
2. Start Sensor stream
3. Calling
tegra_mipi_wait()to check for MIPI Cal status.So as mipi cal clk need to be kept enabled till 3rd step, we can enable clock during
tegra_mipi_calibrate()and leave it enabled and disable it integra_mipi_waitafter status check.
From TRM:
The following sequence is recommended for capturing a single frame:
1. Set up CSI registers for use case such as number of lanes, virtual channel, etc.
2. Initialize and power up CSI interface
3. Wait for initialization time or done signal from calibration logic
4. Power up camera through the I2C interface
5. All CSI data and clock lanes are in stop state, LP11
6. Initiate frame capture through the I2C
7. Frame done, CSI goes back to stop state, LP11
Hence, is it really necessary to perform the manual calibration?
Sowjanya Komatineni
maintainerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
Quoted 47 lines · Dmitry Osipenko
17.07.2020 02:09, Sowjanya Komatineni пишет:
Quoted 26 lines · Sowjanya Komatineni
Quoted 15 lines · Dmitry Osipenko
Quoted 14 lines
17.07.2020 01:49, Sowjanya Komatineni пишет:
Quoted 13 lines
Quoted 2 lines
What keeps MIPI clock enabled after completion of the
tegra_mipi_calibrate()invocation?MIPI clock is disabled at end of
tegra_mipi_calibrateand is re-enabled duringtegra_mipi_wait.I think I should fix this to keep the clock enabled till calibration results are latched.
All consumers of
tegra_mipi_calibrate()will calltegra_mipi_wait().So will remove
clk_disablemipi clk at end oftegra_mipi_calibrate()andclk_enablemipi_clkat beginning oftegra_mipi_wait()Quoted 7 lines
Quoted 2 lines
Isn't it possible to perform the calibration after enabling CSI and before of starting the sensor streaming?
Currently this is what I am doing. Triggering calibration start during CSI receiver being ready and then sensor streaming will happen where internal MIPI CAL detects for LP -> HS transition and applies results to pads. So checking for calibration results after sensor stream is enabled
1. Calling
tegra_mipi_calibrate()during CSI streaming where CSI pads are enabled and receiver is kept readyQuoted 7 lines
2. Start Sensor stream
3. Calling
tegra_mipi_wait()to check for MIPI Cal status.So as mipi cal clk need to be kept enabled till 3rd step, we can enable clock during
tegra_mipi_calibrate()and leave it enabled and disable it integra_mipi_waitafter status check.From TRM:
The following sequence is recommended for capturing a single frame:
1. Set up CSI registers for use case such as number of lanes, virtual channel, etc.
2. Initialize and power up CSI interface
3. Wait for initialization time or done signal from calibration logic
4. Power up camera through the I2C interface
5. All CSI data and clock lanes are in stop state, LP11
6. Initiate frame capture through the I2C
7. Frame done, CSI goes back to stop state, LP11
Quoted 1 line
Hence, is it really necessary to perform the manual calibration?
done signal from calibration logic will happen only when it sees LP to HS transition as thats when calibration results are applied to pads and then done signal is set.
Also MIPI Pads calibration need to be done on every power off/on. So need to do calibration and trigger it along with CSI receiver programming to keep it ready and then need to check/wait for status only after sensor stream happens as thats where LP->HS transition happen.
Sowjanya Komatineni
maintainerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
Quoted 49 lines · Sowjanya Komatineni
Quoted 47 lines · Dmitry Osipenko
17.07.2020 02:09, Sowjanya Komatineni пишет:
Quoted 26 lines · Sowjanya Komatineni
Quoted 15 lines · Dmitry Osipenko
Quoted 14 lines
17.07.2020 01:49, Sowjanya Komatineni пишет:
Quoted 13 lines
Quoted 2 lines
What keeps MIPI clock enabled after completion of the
tegra_mipi_calibrate()invocation?MIPI clock is disabled at end of
tegra_mipi_calibrateand is re-enabled duringtegra_mipi_wait.I think I should fix this to keep the clock enabled till calibration results are latched.
All consumers of
tegra_mipi_calibrate()will calltegra_mipi_wait().So will remove
clk_disablemipi clk at end oftegra_mipi_calibrate()andclk_enablemipi_clkat beginning oftegra_mipi_wait()Quoted 7 lines
Quoted 2 lines
Isn't it possible to perform the calibration after enabling CSI and before of starting the sensor streaming?
Currently this is what I am doing. Triggering calibration start during CSI receiver being ready and then sensor streaming will happen where internal MIPI CAL detects for LP -> HS transition and applies results to pads. So checking for calibration results after sensor stream is enabled
1. Calling
tegra_mipi_calibrate()during CSI streaming where CSI pads are enabled and receiver is kept readyQuoted 7 lines
2. Start Sensor stream
3. Calling
tegra_mipi_wait()to check for MIPI Cal status.So as mipi cal clk need to be kept enabled till 3rd step, we can enable clock during
tegra_mipi_calibrate()and leave it enabled and disable it integra_mipi_waitafter status check.From TRM:
The following sequence is recommended for capturing a single frame:
1. Set up CSI registers for use case such as number of lanes, virtual channel, etc.
2. Initialize and power up CSI interface
3. Wait for initialization time or done signal from calibration logic
4. Power up camera through the I2C interface
5. All CSI data and clock lanes are in stop state, LP11
6. Initiate frame capture through the I2C
7. Frame done, CSI goes back to stop state, LP11
Quoted 6 lines
Quoted 1 line
Hence, is it really necessary to perform the manual calibration?
done signal from calibration logic will happen only when it sees LP to HS transition as thats when calibration results are applied to pads and then done signal is set.
Also MIPI Pads calibration need to be done on every power off/on. So need to do calibration and trigger it along with CSI receiver programming to keep it ready and then need to check/wait for status only after sensor stream happens as thats where
LP->HStransition happen.
Looks like sequence posted in TRM need to be updated clearly for proper MIPI CAL start and wait.
Correct steps should be like below
1. Set up CSI registers for use case such as number of lanes, virtual channel, etc.
2. Initialize and power up CSI CIL interface
3. Program MIPI CAL bias pads, cal configs, cal control registers and enable calibration start
4. Power up camera through the I2C interface and start sensor streaming through the I2C
Note: All sensors might not leave pads in LP-11 state as sensor may be power down when not in use.
So start streaming prior to checking for calibration done status as LP-11 -> HS transition happens during sensor stream and calibration logic can apply results to pads and update done status,
5. Wait for done signal from calibration logic
6. perform frame capture thru VI
7. Frame done, CSI goes back to stop state, LP11
Will work internally to correct sequence in TRM ...
In mipi driver will update as below to have mipi clk enabled till calibration status check is done.
Always tegra_mipi_wait() followes tegra_mipi_calibrate() in both DSI and CSI. So below sequence should work good.
tegra_mipi_calibrate()
- clk_enable mipi cal
- program mipi cal registers (bias pads cfgs, mipi cal ctrl and trigger calibration start)
tegra_mipi_wait()
- read mipi cal status and wait for active and done bits
- clk_disable mipi cal
Thanks
Sowjanya
Dmitry Osipenko
reviewerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
17.07.2020 07:46, Sowjanya Komatineni пишет:
...
Quoted 20 lines
Looks like sequence posted in TRM need to be updated clearly for proper MIPI CAL start and wait.
Correct steps should be like below
1. Set up CSI registers for use case such as number of lanes, virtual channel, etc.
2. Initialize and power up CSI CIL interface
3. Program MIPI CAL bias pads, cal configs, cal control registers and enable calibration start
4. Power up camera through the I2C interface and start sensor streaming through the I2CNote: All sensors might not leave pads in LP-11 state as sensor may be power down when not in use.
So start streaming prior to checking for calibration done status as LP-11 -> HS transition happens during sensor stream and calibration logic can apply results to pads and update done status,
Quoted 6 lines
5. Wait for done signal from calibration logic
6. perform frame capture thru VI
7. Frame done, CSI goes back to stop state, LP11Will work internally to correct sequence in TRM ...
Will be nice to have an updated TRM, thank you!
Also, what about the auto-calibration? Isn't it needed to be enabled for CSI?
Quoted 8 lines
In mipi driver will update as below to have mipi clk enabled till calibration status check is done.
Always
tegra_mipi_wait()followestegra_mipi_calibrate()in both DSI and CSI. So below sequence should work good.
tegra_mipi_calibrate()
Quoted 7 lines
-
clk_enablemipi cal
- program mipi cal registers (bias pads cfgs, mipi cal ctrl and trigger calibration start)
tegra_mipi_wait()
- read mipi cal status and wait for active and done bits
-clk_disablemipi cal
Maybe then it should be better to rename the functions like this:
tegra_mipi_calibrate() -> tegra_mipi_start_calibration()tegra_mipi_wait() -> tegra_mipi_finish_calibration().
and there also should be tegra_mipi_cancel_calibration().
Example:
tegra_mipi_start_calibration();
ret = v4l2_subdev_call(subdev, video, s_stream, on);
if (ret < 0) {
tegra_mipi_cancel_calibration();
goto err;
}
tegra_mipi_finish_calibration();Sowjanya Komatineni
maintainerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
Quoted 24 lines · Dmitry Osipenko
17.07.2020 07:46, Sowjanya Komatineni пишет:
...Quoted 22 lines
Looks like sequence posted in TRM need to be updated clearly for proper MIPI CAL start and wait.
Correct steps should be like below
1. Set up CSI registers for use case such as number of lanes, virtual channel, etc.
2. Initialize and power up CSI CIL interface
3. Program MIPI CAL bias pads, cal configs, cal control registers and enable calibration start
4. Power up camera through the I2C interface and start sensor streaming through the I2CNote: All sensors might not leave pads in LP-11 state as sensor may be power down when not in use.
So start streaming prior to checking for calibration done status as LP-11 -> HS transition happens during sensor stream and calibration logic can apply results to pads and update done status,
5. Wait for done signal from calibration logic
Quoted 8 lines
Quoted 4 lines
6. perform frame capture thru VI
7. Frame done, CSI goes back to stop state, LP11Will work internally to correct sequence in TRM ...
Will be nice to have an updated TRM, thank you!
Also, what about the auto-calibration? Isn't it needed to be enabled for CSI?
STARTCAL does one time calibration and with AUTOCAL calibration will be triggered periodically.
For pads PULLUP/PULLDN/TERM impedance calibration, we only need one-time calibration on pads power up.
We always use one time pads calibration for CSI.
Quoted 38 lines
Quoted 9 lines
In mipi driver will update as below to have mipi clk enabled till calibration status check is done.
Always
tegra_mipi_wait()followestegra_mipi_calibrate()in both DSI and CSI. So below sequence should work good.
tegra_mipi_calibrate()Quoted 7 lines
-
clk_enablemipi cal
- program mipi cal registers (bias pads cfgs, mipi cal ctrl and trigger calibration start)
tegra_mipi_wait()
- read mipi cal status and wait for active and done bits
-clk_disablemipi calMaybe then it should be better to rename the functions like this:
tegra_mipi_calibrate()->tegra_mipi_start_calibration()tegra_mipi_wait()->tegra_mipi_finish_calibration().and there also should be
tegra_mipi_cancel_calibration().Example:
tegra_mipi_start_calibration(); ret = v4l2_subdev_call(subdev, video, s_stream, on); if (ret < 0) { tegra_mipi_cancel_calibration(); goto err; } tegra_mipi_finish_calibration();
Dmitry Osipenko
reviewerRe: [RFC PATCH v3 16/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
17.07.2020 18:41, Sowjanya Komatineni пишет:
...
Quoted 9 lines
Quoted 2 lines
Also, what about the auto-calibration? Isn't it needed to be enabled for CSI?
STARTCAL does one time calibration and with AUTOCAL calibration will be triggered periodically.
For pads PULLUP/PULLDN/TERM impedance calibration, we only need one-time calibration on pads power up.
We always use one time pads calibration for CSI.
Alright, thank you for the clarification!
Sowjanya Komatineni
maintainerRFC PATCH v3 17/18 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/csi.c | 44 +++++++++++++++++++++++++++++++-- drivers/staging/media/tegra-video/csi.h | 2 ++ drivers/staging/media/tegra-video/vi.c | 16 ++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-)
drivers/staging/media/tegra-video/csi.c +42 -2
@@ -252,15 +252,42 @@ static int tegra_csi_s_stream(struct v4l2_subdev *subdev, int enable)return ret; } +if (csi_chan->mipi) { + ret =tegra_mipi_enable (csi_chan->mipi); +if (ret <0 ) { +dev_err (csi->dev, +"failed to enable MIPI pads: %d\n" , + ret); + goto rpm_put; + } + +/* +* CSI MIPI pads PULLUP, PULLDN and TERM impedances +* need to be calibrated after power on. +* So, trigger the calibration start here and results +* will be latched and applied to the pads when link is +* in LP11 state during start of sensor streaming. +*/ +tegra_mipi_calibrate (csi_chan->mipi); + } + ret = csi->ops->csi_start_streaming (csi_chan);if (ret <0 ) - goto rpm_put; + goto disable_mipi;return 0 ; } csi->ops->csi_stop_streaming (csi_chan); +disable_mipi: +if (csi_chan->mipi) { + ret =tegra_mipi_disable (csi_chan->mipi); +if (ret <0 ) +dev_err (csi->dev, +"failed to disable MIPI pads: %d\n" , ret); + } + rpm_put:pm_runtime_put (csi->dev);return ret;
@@ -294,6 +321,7 @@ static int tegra_csi_channel_alloc(struct tegra_csi *csi, unsigned int num_pads) {struct tegra_csi_channel *chan; +int ret =0 ; chan =kzalloc (sizeof (*chan),GFP_KERNEL );if (!chan)
@@ -312,7 +340,16 @@ static int tegra_csi_channel_alloc(struct tegra_csi *csi, chan->pads[0 ].flags =MEDIA_PAD_FL_SOURCE ; } -return 0 ; +if (IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG )) +return 0 ; + + chan->mipi =tegra_mipi_request (csi->dev, node); +if (IS_ERR (chan->mipi)) { + ret =PTR_ERR (chan->mipi); +dev_err (csi->dev,"failed to get mipi device: %d\n" , ret); + } + +return ret; }static int tegra_csi_tpg_channels_alloc (struct tegra_csi *csi)
@@ -475,6 +512,9 @@ static void tegra_csi_channels_cleanup(struct tegra_csi *csi)struct tegra_csi_channel *chan, *tmp;list_for_each_entry_safe (chan, tmp, &csi->csi_chans, list) { +if (chan->mipi) +tegra_mipi_free (chan->mipi); + subdev = &chan->subdev;if (subdev->dev) {if (!IS_ENABLED (CONFIG_VIDEO_TEGRA_TPG ))
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 +16 -0
@@ -191,6 +191,7 @@ tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan)int tegra_channel_set_stream (struct tegra_vi_channel *chan,bool on) {struct v4l2_subdev *subdev, *csi_subdev, *src_subdev; +struct tegra_csi_channel *csi_chan;int ret; csi_subdev =tegra_channel_get_remote_csi_subdev (chan);
@@ -213,6 +214,21 @@ int tegra_channel_set_stream(struct tegra_vi_channel *chan, bool on)if (ret <0 && ret != -ENOIOCTLCMD )return ret; +/* +* CSI subdev stream-on triggers start of MIPI pads calibration. +* Calibration results are latched and applied to the pads when +* link is in LP11 state which will happen during sensor stream-on. +* So, wait for pads calibration to complete here. +*/ + csi_chan =v4l2_get_subdevdata (csi_subdev); +if (on && csi_chan->mipi) { + ret =tegra_mipi_wait (csi_chan->mipi); +if (ret <0 ) +dev_err (csi_chan->csi->dev, +"MIPI calibration failed: %d\n" , ret); +return ret; + } +return 0 ; }
Signature · 1 line
2.7.4
Sowjanya Komatineni
maintainerRFC PATCH v3 18/18 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/csi.c | 55 ++++++++++++++++++++++++++++ drivers/staging/media/tegra-video/csi.h | 5 +++ drivers/staging/media/tegra-video/tegra210.c | 17 ++++++++- 3 files changed, 75 insertions(+), 2 deletions(-)
drivers/staging/media/tegra-video/csi.c +55 -0
@@ -19,6 +19,8 @@#include "csi.h" #include "video.h" +#define MHZ 1000000 +static inline struct tegra_csi *host1x_client_to_csi (struct host1x_client *client) {
@@ -235,6 +237,59 @@ static int tegra_csi_g_frame_interval(struct v4l2_subdev *subdev,return 0 ; } +static unsigned int csi_get_pixel_rate (struct tegra_csi_channel *csi_chan) +{ +struct tegra_vi_channel *chan; +struct v4l2_subdev *src_subdev; +struct v4l2_ctrl *ctrl; + + chan =v4l2_get_subdev_hostdata (&csi_chan->subdev); + src_subdev =tegra_channel_get_remote_source_subdev (chan); + ctrl =v4l2_ctrl_find (src_subdev->ctrl_handler,V4L2_CID_PIXEL_RATE ); +if (ctrl) +return v4l2_ctrl_g_ctrl_int64 (ctrl); + +return 0 ; +} + +void tegra_csi_calc_settle_time (struct tegra_csi_channel *csi_chan, +u8 *clk_settle_time, +u8 *ths_settle_time) +{ +struct tegra_csi *csi = csi_chan->csi; +unsigned int cil_clk_mhz; +unsigned int pix_clk_mhz; +int clk_idx = (csi_chan->csi_port_num >>1 ) +1 ; + + cil_clk_mhz =clk_get_rate (csi->clks[clk_idx].clk) /MHZ ; + pix_clk_mhz =csi_get_pixel_rate (csi_chan) /MHZ ; + +/* +* CLK Settle time is the interval during which HS receiver should +* ignore any clock lane HS transitions, starting from the beginning +* of T-CLK-PREPARE. +* Per DPHY specification, T-CLK-SETTLE should be between 95ns ~ 300ns +* +* 95ns < (clk-settle-programmed + 7) * lp clk period < 300ns +* midpoint = 197.5 ns +*/ + *clk_settle_time = ((95 +300 ) * cil_clk_mhz -14000 ) /2000 ; + +/* +* THS Settle time is the interval during which HS receiver should +* ignore any data lane HS transitions, starting from the beginning +* of THS-PREPARE. +* +* Per DPHY specification, T-HS-SETTLE should be between 85ns + 6UI +* and 145ns+10UI. +* 85ns + 6UI < (Ths-settle-prog + 5) * lp_clk_period < 145ns + 10UI +* midpoint = 115ns + 8UI +*/ +if (pix_clk_mhz) + *ths_settle_time = (115 * cil_clk_mhz +8000 * cil_clk_mhz + / (2 * pix_clk_mhz) -5000 ) /1000 ; +} +static int tegra_csi_s_stream (struct v4l2_subdev *subdev,int enable) {struct tegra_vi_channel *chan =v4l2_get_subdev_hostdata (subdev);
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
Hi Sowjanya,
Quoted 24 lines · Sowjanya Komatineni
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 IMX219 camera sensor.
This series include,
VI I2C related fixes
- Camera sensor programming happens through VI I2C which is on host1x bus.
- These patches includes device tree and I2C driver fixes for VI I2C.Tegra video driver updates
- TPG Vs Non-TPG based onKconfig
- 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.
Quoted 7 lines
Host1x driver updates
- Adds API to allow creating mipi device for specific device node.
- Splits MIPI pads calibrate start and waiting for calibration to be done.Device tree updates
- Adds camera connector 2V8, 1V8, 1V2 regulator supplies to Jetson TX1 DT.
- Enabled VI and CSI support in Jetson Nano DT.
I'm doing a bit of stress testing with:
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
and I see that the imx274 has often streaming failures:
[ 172.025144] IMX274 8-001a: s_stream failed [ 179.025192] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3132 = 870 (2 bytes) [ 179.033575] IMX274 8-001a: s_stream failed [ 226.525378] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3130 = 878 (2 bytes) [ 226.533761] IMX274 8-001a: s_stream failed [ 227.029325] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 227.037758] IMX274 8-001a: s_stream failed [ 247.025218] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 247.033658] IMX274 8-001a: s_stream failed [ 293.025517] IMX274 8-001a: s_stream failed [ 309.024727] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30e0 = 0 (2 bytes) [ 309.032969] IMX274 8-001a: s_stream failed [ 309.529506] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f8 = 11d2 (3 bytes) [ 309.538103] IMX274 8-001a: imx274_set_frame_length error = -121 [ 309.544102] IMX274 8-001a: imx274_set_frame_interval error = -121 [ 309.550243] IMX274 8-001a: s_stream failed [ 314.025561] IMX274 8-001a: s_stream failed [ 329.025586] IMX274 8-001a: s_stream failed [ 340.529567] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 303a = f0c (2 bytes) [ 340.538009] IMX274 8-001a: s_stream failed [ 347.525627] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 347.534008] IMX274 8-001a: s_stream failed [ 365.033640] IMX274 8-001a: s_stream failed [ 437.525788] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3038 = c (2 bytes) [ 437.533997] IMX274 8-001a: s_stream failed [ 456.029780] IMX274 8-001a: s_stream failed [ 472.025862] IMX274 8-001a: s_stream failed [ 498.025861] IMX274 8-001a: s_stream failed [ 500.025905] IMX274 8-001a: s_stream failed
where v4l2-ctl returns:
VIDIOC_STREAMON returned -1 (Remote I/O error)
I don't see this with the imx219.
I also see this occasionally:
[Fri Jul 17 12:51:42 2020] video4linux video1: failed to run capture start kthread: -4
Something is not stable here.
Regards,
Hans
Quoted 69 lines
Delta between patch versions:
[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
- droppedvb2_queue_releasefrom driver and usingvb2_video_unregister_deviceinstead ofvideo_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.htmlNote:
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.
- Updatetegra_mipi_request()to take device node pointer argument rather than adding extra API.
- Remove checking for clk pointer beforeclk_disable.Sowjanya Komatineni (18):
dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and
power-domains
arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
i2c: tegra: Remove NULL pointer check before
clk_enable/disable/prepare/unprepare
i2c: tegra: Fix the error path integra_i2c_runtime_resume
i2c: tegra: Fix runtime resume to re-init VI I2C
i2c: tegra: Avoidtegra_i2c_init_dma()for Tegra210 vi i2c
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: Add support for external sensor capture
media: tegra-video: Add support for selection ioctl ops
gpu: host1x: mipi: Updatetegra_mipi_request()to be node based
gpu: host1x: mipi: Usereadl_relaxed_poll_timeoutintegra_mipi_wait
gpu: host1x: mipi: Splittegra_mipi_calibrateandtegra_mipi_wait
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 ++- .../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt | 19 +- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 + drivers/gpu/drm/tegra/dsi.c | 9 +- drivers/gpu/host1x/mipi.c | 37 +- drivers/i2c/busses/i2c-tegra.c | 101 +-- drivers/staging/media/tegra-video/Kconfig | 7 + drivers/staging/media/tegra-video/csi.c | 247 ++++++- drivers/staging/media/tegra-video/csi.h | 8 + drivers/staging/media/tegra-video/tegra210.c | 25 +- drivers/staging/media/tegra-video/vi.c | 793 +++++++++++++++++++-- drivers/staging/media/tegra-video/vi.h | 25 +- drivers/staging/media/tegra-video/video.c | 23 +- include/linux/host1x.h | 4 +- 14 files changed, 1242 insertions(+), 154 deletions(-)
Sowjanya Komatineni
maintainerQuoted 78 lines · Hans Verkuil
Hi Sowjanya,
Quoted 24 lines · Sowjanya Komatineni
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 IMX219 camera sensor.
This series include,
VI I2C related fixes
- Camera sensor programming happens through VI I2C which is on host1x bus.
- These patches includes device tree and I2C driver fixes for VI I2C.Tegra video driver updates
- TPG Vs Non-TPG based onKconfig
- 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.Quoted 7 lines
Host1x driver updates
- Adds API to allow creating mipi device for specific device node.
- Splits MIPI pads calibrate start and waiting for calibration to be done.Device tree updates
- Adds camera connector 2V8, 1V8, 1V2 regulator supplies to Jetson TX1 DT.
- Enabled VI and CSI support in Jetson Nano DT.I'm doing a bit of stress testing with:
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
and I see that the imx274 has often streaming failures:
[ 172.025144] IMX274 8-001a: s_stream failed [ 179.025192] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3132 = 870 (2 bytes) [ 179.033575] IMX274 8-001a: s_stream failed [ 226.525378] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3130 = 878 (2 bytes) [ 226.533761] IMX274 8-001a: s_stream failed [ 227.029325] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 227.037758] IMX274 8-001a: s_stream failed [ 247.025218] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 247.033658] IMX274 8-001a: s_stream failed [ 293.025517] IMX274 8-001a: s_stream failed [ 309.024727] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30e0 = 0 (2 bytes) [ 309.032969] IMX274 8-001a: s_stream failed [ 309.529506] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f8 = 11d2 (3 bytes) [ 309.538103] IMX274 8-001a: imx274_set_frame_length error = -121 [ 309.544102] IMX274 8-001a: imx274_set_frame_interval error = -121 [ 309.550243] IMX274 8-001a: s_stream failed [ 314.025561] IMX274 8-001a: s_stream failed [ 329.025586] IMX274 8-001a: s_stream failed [ 340.529567] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 303a = f0c (2 bytes) [ 340.538009] IMX274 8-001a: s_stream failed [ 347.525627] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 347.534008] IMX274 8-001a: s_stream failed [ 365.033640] IMX274 8-001a: s_stream failed [ 437.525788] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3038 = c (2 bytes) [ 437.533997] IMX274 8-001a: s_stream failed [ 456.029780] IMX274 8-001a: s_stream failed [ 472.025862] IMX274 8-001a: s_stream failed [ 498.025861] IMX274 8-001a: s_stream failed [ 500.025905] IMX274 8-001a: s_stream failedwhere v4l2-ctl returns:
VIDIOC_STREAMONreturned -1 (Remote I/O error)I don't see this with the imx219.
I also see this occasionally:
Quoted 7 lines
[Fri Jul 17 12:51:42 2020] video4linux video1: failed to run capture start kthread: -4Something is not stable here.
Regards,
Hans
Hi Hans,
Running the same single frame continuous loop for more than 2 hours now and I don't see any failure.
Above failure shows i2c bulk writes to IMX274 failure due to which s_stream also failed.
Not sure if its due to i2c mux in the path to sensor on your module causing some issue when there is more i2c write traffic as we are doing single stream in continuous loop. Also IMX219 does not show on your side so something specific to IMX274 setup probably.
Regarding kthread_run failure where kthread_run() returned -EINTR during capture start thread, I always see this happen at the point of stopping the continuous single stream while loop by pressing ctrl+c after few loops of execution.
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
when we stop loop with ctrl+c, v4l2-ctl terminates but loop does not terminate immediately and probably SIGKILLed is seen prior to complete.
Using below can help to terminate loop as well when we stop ctrl-c and with this I don't see any repro of EINTR error from kthread_run when run in infinite loop.
while true; do ./v4l2-ctl --stream-mmap --stream-count=1 || break; done
Quoted 68 lines
Quoted 68 lines
Delta between patch versions:
[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
- droppedvb2_queue_releasefrom driver and usingvb2_video_unregister_deviceinstead ofvideo_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.htmlNote:
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.
- Updatetegra_mipi_request()to take device node pointer argument rather than adding extra API.
- Remove checking for clk pointer beforeclk_disable.Sowjanya Komatineni (18):
dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and
power-domains
arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
i2c: tegra: Remove NULL pointer check before
clk_enable/disable/prepare/unprepare
i2c: tegra: Fix the error path integra_i2c_runtime_resume
i2c: tegra: Fix runtime resume to re-init VI I2C
i2c: tegra: Avoidtegra_i2c_init_dma()for Tegra210 vi i2c
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: Add support for external sensor capture
media: tegra-video: Add support for selection ioctl ops
gpu: host1x: mipi: Updatetegra_mipi_request()to be node based
gpu: host1x: mipi: Usereadl_relaxed_poll_timeoutintegra_mipi_wait
gpu: host1x: mipi: Splittegra_mipi_calibrateandtegra_mipi_wait
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 ++- .../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt | 19 +- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 + drivers/gpu/drm/tegra/dsi.c | 9 +- drivers/gpu/host1x/mipi.c | 37 +- drivers/i2c/busses/i2c-tegra.c | 101 +-- drivers/staging/media/tegra-video/Kconfig | 7 + drivers/staging/media/tegra-video/csi.c | 247 ++++++- drivers/staging/media/tegra-video/csi.h | 8 + drivers/staging/media/tegra-video/tegra210.c | 25 +- drivers/staging/media/tegra-video/vi.c | 793 +++++++++++++++++++-- drivers/staging/media/tegra-video/vi.h | 25 +- drivers/staging/media/tegra-video/video.c | 23 +- include/linux/host1x.h | 4 +- 14 files changed, 1242 insertions(+), 154 deletions(-)
Quoted 93 lines · Sowjanya Komatineni
Quoted 78 lines · Hans Verkuil
Hi Sowjanya,
Quoted 24 lines · Sowjanya Komatineni
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 IMX219 camera sensor.
This series include,
VI I2C related fixes
- Camera sensor programming happens through VI I2C which is on host1x bus.
- These patches includes device tree and I2C driver fixes for VI I2C.Tegra video driver updates
- TPG Vs Non-TPG based onKconfig
- 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.Quoted 7 lines
Host1x driver updates
- Adds API to allow creating mipi device for specific device node.
- Splits MIPI pads calibrate start and waiting for calibration to be done.Device tree updates
- Adds camera connector 2V8, 1V8, 1V2 regulator supplies to Jetson TX1 DT.
- Enabled VI and CSI support in Jetson Nano DT.I'm doing a bit of stress testing with:
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
and I see that the imx274 has often streaming failures:
[ 172.025144] IMX274 8-001a: s_stream failed [ 179.025192] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3132 = 870 (2 bytes) [ 179.033575] IMX274 8-001a: s_stream failed [ 226.525378] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3130 = 878 (2 bytes) [ 226.533761] IMX274 8-001a: s_stream failed [ 227.029325] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 227.037758] IMX274 8-001a: s_stream failed [ 247.025218] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 247.033658] IMX274 8-001a: s_stream failed [ 293.025517] IMX274 8-001a: s_stream failed [ 309.024727] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30e0 = 0 (2 bytes) [ 309.032969] IMX274 8-001a: s_stream failed [ 309.529506] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f8 = 11d2 (3 bytes) [ 309.538103] IMX274 8-001a: imx274_set_frame_length error = -121 [ 309.544102] IMX274 8-001a: imx274_set_frame_interval error = -121 [ 309.550243] IMX274 8-001a: s_stream failed [ 314.025561] IMX274 8-001a: s_stream failed [ 329.025586] IMX274 8-001a: s_stream failed [ 340.529567] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 303a = f0c (2 bytes) [ 340.538009] IMX274 8-001a: s_stream failed [ 347.525627] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 347.534008] IMX274 8-001a: s_stream failed [ 365.033640] IMX274 8-001a: s_stream failed [ 437.525788] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3038 = c (2 bytes) [ 437.533997] IMX274 8-001a: s_stream failed [ 456.029780] IMX274 8-001a: s_stream failed [ 472.025862] IMX274 8-001a: s_stream failed [ 498.025861] IMX274 8-001a: s_stream failed [ 500.025905] IMX274 8-001a: s_stream failedwhere v4l2-ctl returns:
VIDIOC_STREAMONreturned -1 (Remote I/O error)I don't see this with the imx219.
I also see this occasionally:
Quoted 7 lines
[Fri Jul 17 12:51:42 2020] video4linux video1: failed to run capture start kthread: -4Something is not stable here.
Regards,
Hans
Hi Hans,
Running the same single frame continuous loop for more than 2 hours now and I don't see any failure.
Quoted 7 lines
Above failure shows i2c bulk writes to IMX274 failure due to which
s_streamalso failed.Not sure if its due to i2c mux in the path to sensor on your module causing some issue when there is more i2c write traffic as we are doing single stream in continuous loop. Also IMX219 does not show on your side so something specific to IMX274 setup probably.
I'll take a closer look next week. Good to know that it works fine for you.
Quoted 6 lines
Regarding
kthread_runfailure wherekthread_run()returned-EINTRduring capture start thread, I always see this happen at the point of stopping the continuous single stream while loop by pressing ctrl+c after few loops of execution.
Hmm, if this is normal behavior, then should this message be a debug message only? Or perhaps only show the message if the error code != EINTR.
Regards,
Hans
Quoted 82 lines
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
when we stop loop with ctrl+c, v4l2-ctl terminates but loop does not terminate immediately and probably SIGKILLed is seen prior to complete.
Using below can help to terminate loop as well when we stop ctrl-c and with this I don't see any repro of EINTR error from
kthread_runwhen run in infinite loop.while true; do ./v4l2-ctl --stream-mmap --stream-count=1 || break; done
Quoted 68 lines
Quoted 68 lines
Delta between patch versions:
[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
- droppedvb2_queue_releasefrom driver and usingvb2_video_unregister_deviceinstead ofvideo_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.htmlNote:
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.
- Updatetegra_mipi_request()to take device node pointer argument rather than adding extra API.
- Remove checking for clk pointer beforeclk_disable.Sowjanya Komatineni (18):
dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and
power-domains
arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
i2c: tegra: Remove NULL pointer check before
clk_enable/disable/prepare/unprepare
i2c: tegra: Fix the error path integra_i2c_runtime_resume
i2c: tegra: Fix runtime resume to re-init VI I2C
i2c: tegra: Avoidtegra_i2c_init_dma()for Tegra210 vi i2c
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: Add support for external sensor capture
media: tegra-video: Add support for selection ioctl ops
gpu: host1x: mipi: Updatetegra_mipi_request()to be node based
gpu: host1x: mipi: Usereadl_relaxed_poll_timeoutintegra_mipi_wait
gpu: host1x: mipi: Splittegra_mipi_calibrateandtegra_mipi_wait
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 ++- .../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt | 19 +- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 + drivers/gpu/drm/tegra/dsi.c | 9 +- drivers/gpu/host1x/mipi.c | 37 +- drivers/i2c/busses/i2c-tegra.c | 101 +-- drivers/staging/media/tegra-video/Kconfig | 7 + drivers/staging/media/tegra-video/csi.c | 247 ++++++- drivers/staging/media/tegra-video/csi.h | 8 + drivers/staging/media/tegra-video/tegra210.c | 25 +- drivers/staging/media/tegra-video/vi.c | 793 +++++++++++++++++++-- drivers/staging/media/tegra-video/vi.h | 25 +- drivers/staging/media/tegra-video/video.c | 23 +- include/linux/host1x.h | 4 +- 14 files changed, 1242 insertions(+), 154 deletions(-)
Sowjanya Komatineni
maintainerQuoted 102 lines · Hans Verkuil
Quoted 91 lines · Sowjanya Komatineni
Quoted 78 lines · Hans Verkuil
Hi Sowjanya,
Quoted 24 lines · Sowjanya Komatineni
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 IMX219 camera sensor.
This series include,
VI I2C related fixes
- Camera sensor programming happens through VI I2C which is on host1x bus.
- These patches includes device tree and I2C driver fixes for VI I2C.Tegra video driver updates
- TPG Vs Non-TPG based onKconfig
- 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.Quoted 7 lines
Host1x driver updates
- Adds API to allow creating mipi device for specific device node.
- Splits MIPI pads calibrate start and waiting for calibration to be done.Device tree updates
- Adds camera connector 2V8, 1V8, 1V2 regulator supplies to Jetson TX1 DT.
- Enabled VI and CSI support in Jetson Nano DT.I'm doing a bit of stress testing with:
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
and I see that the imx274 has often streaming failures:
[ 172.025144] IMX274 8-001a: s_stream failed [ 179.025192] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3132 = 870 (2 bytes) [ 179.033575] IMX274 8-001a: s_stream failed [ 226.525378] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3130 = 878 (2 bytes) [ 226.533761] IMX274 8-001a: s_stream failed [ 227.029325] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 227.037758] IMX274 8-001a: s_stream failed [ 247.025218] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 247.033658] IMX274 8-001a: s_stream failed [ 293.025517] IMX274 8-001a: s_stream failed [ 309.024727] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30e0 = 0 (2 bytes) [ 309.032969] IMX274 8-001a: s_stream failed [ 309.529506] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f8 = 11d2 (3 bytes) [ 309.538103] IMX274 8-001a: imx274_set_frame_length error = -121 [ 309.544102] IMX274 8-001a: imx274_set_frame_interval error = -121 [ 309.550243] IMX274 8-001a: s_stream failed [ 314.025561] IMX274 8-001a: s_stream failed [ 329.025586] IMX274 8-001a: s_stream failed [ 340.529567] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 303a = f0c (2 bytes) [ 340.538009] IMX274 8-001a: s_stream failed [ 347.525627] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 30f6 = 107 (2 bytes) [ 347.534008] IMX274 8-001a: s_stream failed [ 365.033640] IMX274 8-001a: s_stream failed [ 437.525788] IMX274 8-001a: imx274_write_mbreg : i2c bulk write failed, 3038 = c (2 bytes) [ 437.533997] IMX274 8-001a: s_stream failed [ 456.029780] IMX274 8-001a: s_stream failed [ 472.025862] IMX274 8-001a: s_stream failed [ 498.025861] IMX274 8-001a: s_stream failed [ 500.025905] IMX274 8-001a: s_stream failedwhere v4l2-ctl returns:
VIDIOC_STREAMONreturned -1 (Remote I/O error)I don't see this with the imx219.
I also see this occasionally:
Quoted 7 lines
[Fri Jul 17 12:51:42 2020] video4linux video1: failed to run capture start kthread: -4Something is not stable here.
Regards,
Hans
Hi Hans,
Running the same single frame continuous loop for more than 2 hours now and I don't see any failure.
Quoted 7 lines
Above failure shows i2c bulk writes to IMX274 failure due to which
s_streamalso failed.Not sure if its due to i2c mux in the path to sensor on your module causing some issue when there is more i2c write traffic as we are doing single stream in continuous loop. Also IMX219 does not show on your side so something specific to IMX274 setup probably.
I'll take a closer look next week. Good to know that it works fine for you.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Regarding
kthread_runfailure wherekthread_run()returned-EINTRduring capture start thread, I always see this happen at the point of stopping the continuous single stream while loop by pressing ctrl+c after few loops of execution.Hmm, if this is normal behavior, then should this message be a debug message only? Or perhaps only show the message if the error code != EINTR.
I believe its good to still show this as its reported by kthread_run -> kthread_create_on_node.
But not sure in real usecase we will ever use while true like this and we should use script to also break while loop along with v4l2-ctl termination when ctrl-c terminate request happens.
Quoted 85 lines
Regards,
Hans
Quoted 80 lines
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
when we stop loop with ctrl+c, v4l2-ctl terminates but loop does not terminate immediately and probably SIGKILLed is seen prior to complete.
Using below can help to terminate loop as well when we stop ctrl-c and with this I don't see any repro of EINTR error from
kthread_runwhen run in infinite loop.while true; do ./v4l2-ctl --stream-mmap --stream-count=1 || break; done
Quoted 67 lines
Quoted 67 lines
Delta between patch versions:
[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
- droppedvb2_queue_releasefrom driver and usingvb2_video_unregister_deviceinstead ofvideo_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.htmlNote:
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.
- Updatetegra_mipi_request()to take device node pointer argument rather than adding extra API.
- Remove checking for clk pointer beforeclk_disable.Sowjanya Komatineni (18):
dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and
power-domains
arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
i2c: tegra: Remove NULL pointer check before
clk_enable/disable/prepare/unprepare
i2c: tegra: Fix the error path integra_i2c_runtime_resume
i2c: tegra: Fix runtime resume to re-init VI I2C
i2c: tegra: Avoidtegra_i2c_init_dma()for Tegra210 vi i2c
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: Add support for external sensor capture
media: tegra-video: Add support for selection ioctl ops
gpu: host1x: mipi: Updatetegra_mipi_request()to be node based
gpu: host1x: mipi: Usereadl_relaxed_poll_timeoutintegra_mipi_wait
gpu: host1x: mipi: Splittegra_mipi_calibrateandtegra_mipi_wait
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 ++- .../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt | 19 +- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 + drivers/gpu/drm/tegra/dsi.c | 9 +- drivers/gpu/host1x/mipi.c | 37 +- drivers/i2c/busses/i2c-tegra.c | 101 +-- drivers/staging/media/tegra-video/Kconfig | 7 + drivers/staging/media/tegra-video/csi.c | 247 ++++++- drivers/staging/media/tegra-video/csi.h | 8 + drivers/staging/media/tegra-video/tegra210.c | 25 +- drivers/staging/media/tegra-video/vi.c | 793 +++++++++++++++++++-- drivers/staging/media/tegra-video/vi.h | 25 +- drivers/staging/media/tegra-video/video.c | 23 +- include/linux/host1x.h | 4 +- 14 files changed, 1242 insertions(+), 154 deletions(-)
Sowjanya Komatineni
maintainerQuoted 112 lines · Sowjanya Komatineni
Quoted 110 lines · Hans Verkuil
Quoted 95 lines · Sowjanya Komatineni
Quoted 82 lines · Hans Verkuil
Hi Sowjanya,
Quoted 31 lines · Sowjanya Komatineni
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 IMX219 camera sensor.
This series include,
VI I2C related fixes
- Camera sensor programming happens through VI I2C which is on host1x bus.
- These patches includes device tree and I2C driver fixes for VI I2C.Tegra video driver updates
- TPG Vs Non-TPG based onKconfig
- 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.Host1x driver updates
- Adds API to allow creating mipi device for specific device node.
- Splits MIPI pads calibrate start and waiting for calibration to be done.Quoted 4 lines
Device tree updates
- Adds camera connector 2V8, 1V8, 1V2 regulator supplies to Jetson TX1 DT.
- Enabled VI and CSI support in Jetson Nano DT.I'm doing a bit of stress testing with:
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
and I see that the imx274 has often streaming failures:
[ 172.025144] IMX274 8-001a:
s_streamfailed
[ 179.025192] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 3132 = 870 (2 bytes) [ 179.033575] IMX274 8-001a:s_streamfailed
[ 226.525378] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 3130 = 878 (2 bytes) [ 226.533761] IMX274 8-001a:s_streamfailed
[ 227.029325] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f6 = 107 (2 bytes) [ 227.037758] IMX274 8-001a:s_streamfailed
[ 247.025218] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f6 = 107 (2 bytes) [ 247.033658] IMX274 8-001a:s_streamfailed
[ 293.025517] IMX274 8-001a:s_streamfailed
[ 309.024727] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30e0 = 0 (2 bytes) [ 309.032969] IMX274 8-001a:s_streamfailed
[ 309.529506] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f8 = 11d2 (3 bytes) [ 309.538103] IMX274 8-001a:imx274_set_frame_lengtherror = -121
[ 309.544102] IMX274 8-001a:imx274_set_frame_intervalerror = -121
[ 309.550243] IMX274 8-001a:s_streamfailed
[ 314.025561] IMX274 8-001a:s_streamfailed
[ 329.025586] IMX274 8-001a:s_streamfailed
[ 340.529567] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 303a = f0c (2 bytes) [ 340.538009] IMX274 8-001a:s_streamfailed
[ 347.525627] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f6 = 107 (2 bytes) [ 347.534008] IMX274 8-001a:s_streamfailed
[ 365.033640] IMX274 8-001a:s_streamfailed
[ 437.525788] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 3038 = c (2 bytes) [ 437.533997] IMX274 8-001a:s_streamfailed
[ 456.029780] IMX274 8-001a:s_streamfailed
[ 472.025862] IMX274 8-001a:s_streamfailed
[ 498.025861] IMX274 8-001a:s_streamfailed
[ 500.025905] IMX274 8-001a:s_streamfailedwhere v4l2-ctl returns:
VIDIOC_STREAMONreturned -1 (Remote I/O error)I don't see this with the imx219.
I also see this occasionally:
Quoted 7 lines
[Fri Jul 17 12:51:42 2020] video4linux video1: failed to run capture start kthread: -4Something is not stable here.
Regards,
Hans
Hi Hans,
Running the same single frame continuous loop for more than 2 hours now and I don't see any failure.
Quoted 7 lines
Above failure shows i2c bulk writes to IMX274 failure due to which
s_streamalso failed.Not sure if its due to i2c mux in the path to sensor on your module causing some issue when there is more i2c write traffic as we are doing single stream in continuous loop. Also IMX219 does not show on your side so something specific to IMX274 setup probably.
I'll take a closer look next week. Good to know that it works fine for you.
Quoted 5 lines
Regarding
kthread_runfailure wherekthread_run()returned-EINTRduring capture start thread, I always see this happen at the point of stopping the continuous single stream while loop by pressing ctrl+c after few loops of execution.
Quoted 8 lines
Quoted 2 lines
Hmm, if this is normal behavior, then should this message be a debug message only? Or perhaps only show the message if the error code != EINTR.
I believe its good to still show this as its reported by
kthread_run->kthread_create_on_node.But not sure in real usecase we will ever use while true like this and we should use script to also break while loop along with v4l2-ctl termination when ctrl-c terminate request happens.
Hi Hans, As this happens only during this type of case, I can update to show message only when error code != EINTR.
Thanks
Sowjanya
Quoted 87 lines
Quoted 87 lines
Regards,
Hans
Quoted 81 lines
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
when we stop loop with ctrl+c, v4l2-ctl terminates but loop does not terminate immediately and probably SIGKILLed is seen prior to complete.
Using below can help to terminate loop as well when we stop ctrl-c and with this I don't see any repro of EINTR error from
kthread_runwhen run in infinite loop.while true; do ./v4l2-ctl --stream-mmap --stream-count=1 || break; done
Quoted 68 lines
Quoted 68 lines
Delta between patch versions:
[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
- droppedvb2_queue_releasefrom driver and usingvb2_video_unregister_deviceinstead ofvideo_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.htmlNote:
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.
- Updatetegra_mipi_request()to take device node pointer argument rather than adding extra API.
- Remove checking for clk pointer beforeclk_disable.Sowjanya Komatineni (18):
dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and power-domains
arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
i2c: tegra: Remove NULL pointer check before clk_enable/disable/prepare/unprepare
i2c: tegra: Fix the error path integra_i2c_runtime_resume
i2c: tegra: Fix runtime resume to re-init VI I2C
i2c: tegra: Avoidtegra_i2c_init_dma()for Tegra210 vi i2c
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: Add support for external sensor capture
media: tegra-video: Add support for selection ioctl ops
gpu: host1x: mipi: Updatetegra_mipi_request()to be node based
gpu: host1x: mipi: Usereadl_relaxed_poll_timeoutintegra_mipi_wait
gpu: host1x: mipi: Splittegra_mipi_calibrateandtegra_mipi_wait
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 ++-
.../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt| 19 +- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 + drivers/gpu/drm/tegra/dsi.c | 9 +- drivers/gpu/host1x/mipi.c | 37 +- drivers/i2c/busses/i2c-tegra.c | 101 +-- drivers/staging/media/tegra-video/Kconfig | 7 + drivers/staging/media/tegra-video/csi.c | 247 ++++++- drivers/staging/media/tegra-video/csi.h | 8 + drivers/staging/media/tegra-video/tegra210.c | 25 +- drivers/staging/media/tegra-video/vi.c | 793
+++++++++++++++++++--
drivers/staging/media/tegra-video/vi.h | 25 +- drivers/staging/media/tegra-video/video.c | 23 +- include/linux/host1x.h | 4 +-14 files changed, 1242 insertions(+), 154 deletions(-)
Sowjanya Komatineni
maintainerQuoted 121 lines · Sowjanya Komatineni
Quoted 119 lines · Sowjanya Komatineni
Quoted 107 lines · Hans Verkuil
Quoted 96 lines · Sowjanya Komatineni
Quoted 83 lines · Hans Verkuil
Hi Sowjanya,
Quoted 32 lines · Sowjanya Komatineni
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 IMX219 camera sensor.
This series include,
VI I2C related fixes
- Camera sensor programming happens through VI I2C which is on host1x bus.
- These patches includes device tree and I2C driver fixes for VI I2C.Tegra video driver updates
- TPG Vs Non-TPG based onKconfig
- 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.Host1x driver updates
- Adds API to allow creating mipi device for specific device node.
- Splits MIPI pads calibrate start and waiting for calibration to be done.Quoted 4 lines
Device tree updates
- Adds camera connector 2V8, 1V8, 1V2 regulator supplies to Jetson TX1 DT.
- Enabled VI and CSI support in Jetson Nano DT.I'm doing a bit of stress testing with:
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
and I see that the imx274 has often streaming failures:
[ 172.025144] IMX274 8-001a:
s_streamfailed
[ 179.025192] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 3132 = 870 (2 bytes) [ 179.033575] IMX274 8-001a:s_streamfailed
[ 226.525378] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 3130 = 878 (2 bytes) [ 226.533761] IMX274 8-001a:s_streamfailed
[ 227.029325] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f6 = 107 (2 bytes) [ 227.037758] IMX274 8-001a:s_streamfailed
[ 247.025218] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f6 = 107 (2 bytes) [ 247.033658] IMX274 8-001a:s_streamfailed
[ 293.025517] IMX274 8-001a:s_streamfailed
[ 309.024727] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30e0 = 0 (2 bytes) [ 309.032969] IMX274 8-001a:s_streamfailed
[ 309.529506] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f8 = 11d2 (3 bytes) [ 309.538103] IMX274 8-001a:imx274_set_frame_lengtherror = -121
[ 309.544102] IMX274 8-001a:imx274_set_frame_intervalerror = -121
[ 309.550243] IMX274 8-001a:s_streamfailed
[ 314.025561] IMX274 8-001a:s_streamfailed
[ 329.025586] IMX274 8-001a:s_streamfailed
[ 340.529567] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 303a = f0c (2 bytes) [ 340.538009] IMX274 8-001a:s_streamfailed
[ 347.525627] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f6 = 107 (2 bytes) [ 347.534008] IMX274 8-001a:s_streamfailed
[ 365.033640] IMX274 8-001a:s_streamfailed
[ 437.525788] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 3038 = c (2 bytes) [ 437.533997] IMX274 8-001a:s_streamfailed
[ 456.029780] IMX274 8-001a:s_streamfailed
[ 472.025862] IMX274 8-001a:s_streamfailed
[ 498.025861] IMX274 8-001a:s_streamfailed
[ 500.025905] IMX274 8-001a:s_streamfailedwhere v4l2-ctl returns:
VIDIOC_STREAMONreturned -1 (Remote I/O error)I don't see this with the imx219.
I also see this occasionally:
Quoted 7 lines
[Fri Jul 17 12:51:42 2020] video4linux video1: failed to run capture start kthread: -4Something is not stable here.
Regards,
Hans
Hi Hans,
Running the same single frame continuous loop for more than 2 hours now and I don't see any failure.
Quoted 7 lines
Above failure shows i2c bulk writes to IMX274 failure due to which
s_streamalso failed.Not sure if its due to i2c mux in the path to sensor on your module causing some issue when there is more i2c write traffic as we are doing single stream in continuous loop. Also IMX219 does not show on your side so something specific to IMX274 setup probably.
I'll take a closer look next week. Good to know that it works fine for you.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Regarding
kthread_runfailure wherekthread_run()returned-EINTRduring capture start thread, I always see this happen at the point of stopping the continuous single stream while loop by pressing ctrl+c after few loops of execution.Hmm, if this is normal behavior, then should this message be a debug message only? Or perhaps only show the message if the error code != EINTR.
I believe its good to still show this as its reported by
kthread_run->kthread_create_on_node.
Quoted 7 lines
Quoted 2 lines
But not sure in real usecase we will ever use while true like this and we should use script to also break while loop along with v4l2-ctl termination when ctrl-c terminate request happens.
Hi Hans, As this happens only during this type of case, I can update to show message only when error code != EINTR.
Thanks
Sowjanya
Sorry, Was thinking to not mask debug message for -EINTR in case if it happens in any other valid scenarios. If you still want to mask, will update in next version.
Quoted 88 lines
Quoted 88 lines
Quoted 88 lines
Regards,
Hans
Quoted 81 lines
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
when we stop loop with ctrl+c, v4l2-ctl terminates but loop does not terminate immediately and probably SIGKILLed is seen prior to complete.
Using below can help to terminate loop as well when we stop ctrl-c and with this I don't see any repro of EINTR error from
kthread_runwhen run in infinite loop.while true; do ./v4l2-ctl --stream-mmap --stream-count=1 || break; done
Quoted 68 lines
Quoted 68 lines
Delta between patch versions:
[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
- droppedvb2_queue_releasefrom driver and usingvb2_video_unregister_deviceinstead ofvideo_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.htmlNote:
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.
- Updatetegra_mipi_request()to take device node pointer argument rather than adding extra API.
- Remove checking for clk pointer beforeclk_disable.Sowjanya Komatineni (18):
dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and power-domains
arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
i2c: tegra: Remove NULL pointer check before clk_enable/disable/prepare/unprepare
i2c: tegra: Fix the error path integra_i2c_runtime_resume
i2c: tegra: Fix runtime resume to re-init VI I2C
i2c: tegra: Avoidtegra_i2c_init_dma()for Tegra210 vi i2c
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: Add support for external sensor capture
media: tegra-video: Add support for selection ioctl ops
gpu: host1x: mipi: Updatetegra_mipi_request()to be node based
gpu: host1x: mipi: Usereadl_relaxed_poll_timeoutintegra_mipi_wait
gpu: host1x: mipi: Splittegra_mipi_calibrateandtegra_mipi_wait
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 ++-
.../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt| 19 +- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 6 + drivers/gpu/drm/tegra/dsi.c | 9 +- drivers/gpu/host1x/mipi.c | 37 +- drivers/i2c/busses/i2c-tegra.c | 101 +-- drivers/staging/media/tegra-video/Kconfig | 7 + drivers/staging/media/tegra-video/csi.c | 247 ++++++- drivers/staging/media/tegra-video/csi.h | 8 + drivers/staging/media/tegra-video/tegra210.c | 25 +- drivers/staging/media/tegra-video/vi.c | 793
+++++++++++++++++++--
drivers/staging/media/tegra-video/vi.h | 25 +- drivers/staging/media/tegra-video/video.c | 23 +- include/linux/host1x.h | 4 +-14 files changed, 1242 insertions(+), 154 deletions(-)
Sowjanya Komatineni
maintainerQuoted 125 lines · Sowjanya Komatineni
Quoted 123 lines · Sowjanya Komatineni
Quoted 121 lines · Sowjanya Komatineni
Quoted 107 lines · Hans Verkuil
Quoted 96 lines · Sowjanya Komatineni
Quoted 83 lines · Hans Verkuil
Hi Sowjanya,
Quoted 32 lines · Sowjanya Komatineni
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 IMX219 camera sensor.
This series include,
VI I2C related fixes
- Camera sensor programming happens through VI I2C which is on host1x bus.
- These patches includes device tree and I2C driver fixes for VI I2C.Tegra video driver updates
- TPG Vs Non-TPG based onKconfig
- 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.Host1x driver updates
- Adds API to allow creating mipi device for specific device node.
- Splits MIPI pads calibrate start and waiting for calibration to be done.Quoted 4 lines
Device tree updates
- Adds camera connector 2V8, 1V8, 1V2 regulator supplies to Jetson TX1 DT.
- Enabled VI and CSI support in Jetson Nano DT.I'm doing a bit of stress testing with:
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
and I see that the imx274 has often streaming failures:
[ 172.025144] IMX274 8-001a:
s_streamfailed
[ 179.025192] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 3132 = 870 (2 bytes) [ 179.033575] IMX274 8-001a:s_streamfailed
[ 226.525378] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 3130 = 878 (2 bytes) [ 226.533761] IMX274 8-001a:s_streamfailed
[ 227.029325] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f6 = 107 (2 bytes) [ 227.037758] IMX274 8-001a:s_streamfailed
[ 247.025218] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f6 = 107 (2 bytes) [ 247.033658] IMX274 8-001a:s_streamfailed
[ 293.025517] IMX274 8-001a:s_streamfailed
[ 309.024727] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30e0 = 0 (2 bytes) [ 309.032969] IMX274 8-001a:s_streamfailed
[ 309.529506] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f8 = 11d2 (3 bytes) [ 309.538103] IMX274 8-001a:imx274_set_frame_lengtherror = -121
[ 309.544102] IMX274 8-001a:imx274_set_frame_intervalerror = -121
[ 309.550243] IMX274 8-001a:s_streamfailed
[ 314.025561] IMX274 8-001a:s_streamfailed
[ 329.025586] IMX274 8-001a:s_streamfailed
[ 340.529567] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 303a = f0c (2 bytes) [ 340.538009] IMX274 8-001a:s_streamfailed
[ 347.525627] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 30f6 = 107 (2 bytes) [ 347.534008] IMX274 8-001a:s_streamfailed
[ 365.033640] IMX274 8-001a:s_streamfailed
[ 437.525788] IMX274 8-001a:imx274_write_mbreg: i2c bulk write failed, 3038 = c (2 bytes) [ 437.533997] IMX274 8-001a:s_streamfailed
[ 456.029780] IMX274 8-001a:s_streamfailed
[ 472.025862] IMX274 8-001a:s_streamfailed
[ 498.025861] IMX274 8-001a:s_streamfailed
[ 500.025905] IMX274 8-001a:s_streamfailedwhere v4l2-ctl returns:
VIDIOC_STREAMONreturned -1 (Remote I/O error)I don't see this with the imx219.
I also see this occasionally:
Quoted 7 lines
[Fri Jul 17 12:51:42 2020] video4linux video1: failed to run capture start kthread: -4Something is not stable here.
Regards,
Hans
Hi Hans,
Running the same single frame continuous loop for more than 2 hours now and I don't see any failure.
Quoted 7 lines
Above failure shows i2c bulk writes to IMX274 failure due to which
s_streamalso failed.Not sure if its due to i2c mux in the path to sensor on your module causing some issue when there is more i2c write traffic as we are doing single stream in continuous loop. Also IMX219 does not show on your side so something specific to IMX274 setup probably.
I'll take a closer look next week. Good to know that it works fine for you.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Regarding
kthread_runfailure wherekthread_run()returned-EINTRduring capture start thread, I always see this happen at the point of stopping the continuous single stream while loop by pressing ctrl+c after few loops of execution.Hmm, if this is normal behavior, then should this message be a debug message only? Or perhaps only show the message if the error code != EINTR.
I believe its good to still show this as its reported by
kthread_run->kthread_create_on_node.But not sure in real usecase we will ever use while true like this and we should use script to also break while loop along with v4l2-ctl termination when ctrl-c terminate request happens.
Quoted 9 lines
Quoted 5 lines
Hi Hans, As this happens only during this type of case, I can update to show message only when error code != EINTR.
Thanks
Sowjanya
Sorry, Was thinking to not mask debug message for
-EINTRin case if it happens in any other valid scenarios. If you still want to mask, will update in next version.
As we are running application that uses threads depending on when ctrl-c gets hit I see sigkill happens during kthread run even with break causing this.
Good way I see it working all the time is to use crtl-z and then kill application as below
Command to run
while true; do ./v4l2-ctl --stream-mmap --stream-count=1; done
To stop ,
press ctrl-z and then execute kill %%
Quoted 88 lines
Quoted 88 lines
Quoted 88 lines
Quoted 88 lines
Regards,
Hans
Quoted 81 lines
while true; do v4l2-ctl --stream-mmap --stream-count=1; done
when we stop loop with ctrl+c, v4l2-ctl terminates but loop does not terminate immediately and probably SIGKILLed is seen prior to complete.
Using below can help to terminate loop as well when we stop ctrl-c and with this I don't see any repro of EINTR error from
kthread_runwhen run in infinite loop.while true; do ./v4l2-ctl --stream-mmap --stream-count=1 || break; done
Quoted 68 lines
Quoted 68 lines
Delta between patch versions:
[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
- droppedvb2_queue_releasefrom driver and usingvb2_video_unregister_deviceinstead ofvideo_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.htmlNote:
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.
- Updatetegra_mipi_request()to take device node pointer argument rather than adding extra API.
- Remove checking for clk pointer beforeclk_disable.Sowjanya Komatineni (18):
dt-bindings: i2c: tegra: Document Tegra210 VI I2C clocks and power-domains
arm64: tegra: Add missing clocks and power-domains to Tegra210 VI I2C
i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
i2c: tegra: Remove NULL pointer check before clk_enable/disable/prepare/unprepare
i2c: tegra: Fix the error path integra_i2c_runtime_resume
i2c: tegra: Fix runtime resume to re-init VI I2C
i2c: tegra: Avoidtegra_i2c_init_dma()for Tegra210 vi i2c
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: Add support for external sensor capture
media: tegra-video: Add support for selection ioctl ops
gpu: host1x: mipi: Updatetegra_mipi_request()to be node based
gpu: host1x: mipi: Usereadl_relaxed_poll_timeoutintegra_mipi_wait
gpu: host1x: mipi: Splittegra_mipi_calibrateandtegra_mipi_wait
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 ++-.../devicetree/bindings/i2c/nvidia,tegra20-i2c.txt| 19 +-arch/arm64/boot/dts/nvidia/tegra210.dtsi| 6 +drivers/gpu/drm/tegra/dsi.c| 9 +-drivers/gpu/host1x/mipi.c| 37 +-drivers/i2c/busses/i2c-tegra.c| 101 +--drivers/staging/media/tegra-video/Kconfig| 7 +drivers/staging/media/tegra-video/csi.c| 247 ++++++-drivers/staging/media/tegra-video/csi.h| 8 +drivers/staging/media/tegra-video/tegra210.c| 25 +-drivers/staging/media/tegra-video/vi.c| 793
+++++++++++++++++++--
drivers/staging/media/tegra-video/vi.h| 25 +-drivers/staging/media/tegra-video/video.c| 23 +-include/linux/host1x.h| 4 +-14 files changed, 1242 insertions(+), 154 deletions(-)