Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp605890ybz; Wed, 15 Apr 2020 15:01:41 -0700 (PDT) X-Received: by 2002:a17:906:c281:: with SMTP id r1mr7106620ejz.310.1586988071015; Wed, 15 Apr 2020 15:01:11 -0700 (PDT) X-Google-Smtp-Source: APiQypLHJaoWvpTsN3ag8MLJJMc6ZwmNpK5sOsRmvHOTFBANZA8g1AjYZqo/JklB+3Eml86cz8lr X-Received: by 2002:a17:906:c281:: with SMTP id r1mr7106476ejz.310.1586988069955; Wed, 15 Apr 2020 15:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586988069; cv=none; d=google.com; s=arc-20160816; b=fGuZit4GX4teYgYdP1BDfaJhFpOxR87R9DVEDVnwv7+oms4QtinToFmASSfgbAgeuL y4MSUkjYD8OdwXqixbA5V8kwMTmGzoh5wugSoaUyriUGH8IsZwoZ79fdvjJImv2scfGk 6mWVfEXSGxKVkeUjeJ3L042YC17mp8uqOw7HneqBWPFIik9+MZWB/8/893piUOnPbRP/ fHqA5EClcB6I58Ft2HL7bbcX5uahmRi/l3nqpHE1E6EktvGJXtpBf7dz5IBQ26IUyeth pK5Ea3rOgdYkdo7ogOxtWGk3qQx8t5BbBUueLZye7KAMOk9HAZvj2XuSpPDBJLF3hIIf gGDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=GwYP6EQZZ/KTY49sAy/uMV+rAlJTmluIz4l6zMjF4kg=; b=lBQv1FhpQpjhNC9duVpCawWrn3GbSJLShSjNOSpr+UgSLc92QfONhUWr7M5bK+d1dq sEcpYOpUrmJRNlfmm5zB9+n3BYlX6opcWvHrtcuK8qW+P5ivnEveIH+1IbG2p7RWGIcm B+/9m9o0SrHIzsq+oVSCSr6iWeQRzzIw2eQyF6qXtpdrYhobHgMhj0IXxW1Ua0Zka5iv XQK8JCaSO+tEOWP2PtdSj2TtRD6hY2ue4DLfQCxr0qUiAHSeM7Mlsm37HUVCD0kcwypP h9Sa0jLGknQxaX1fgUuPIXfrCAW9e7CxFAtguIdPdjA14U8NUB1kpmY+K69J6zCodFbj yiPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz10si7146055ejb.167.2020.04.15.15.00.46; Wed, 15 Apr 2020 15:01:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392585AbgDOBbC (ORCPT + 99 others); Tue, 14 Apr 2020 21:31:02 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:50072 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728332AbgDOBbA (ORCPT ); Tue, 14 Apr 2020 21:31:00 -0400 Received: from floko.floko.floko (unknown [IPv6:2804:431:e7cc:79a2:b6f7:4033:5775:cc3a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: koike) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id ACFE62A1BC8; Wed, 15 Apr 2020 02:30:54 +0100 (BST) From: Helen Koike To: linux-media@vger.kernel.org Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, hans.verkuil@cisco.com, skhan@linuxfoundation.org, niklas.soderlund@ragnatech.se, mchehab@kernel.org, Helen Koike Subject: [PATCH v3 0/4] media: add v4l2_pipeline_stream_{enable,disable} helpers Date: Tue, 14 Apr 2020 22:30:40 -0300 Message-Id: <20200415013044.1778572-1-helen.koike@collabora.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Media drivers need to iterate through the pipeline and call .s_stream() callbacks in the subdevices. Instead of repeating code, add helpers for this. These helpers will go walk through the pipeline only visiting entities that participates in the stream, i.e. it follows links from sink to source (and not the opposite). Which means that in a topology like this https://bit.ly/3b2MxjI calling v4l2_pipeline_stream_enable() from rkisp1_mainpath won't call .s_stream(true) for rkisp1_resizer_selfpath. stream_count variable was added in v4l2_subdevice to handle nested calls to the helpers. This is useful when the driver allows streaming from more then one capture device sharing subdevices. This patch came from the error I was facing when multistreaming from rkisp1 driver, where stoping one capture would call s_stream(false) in the pipeline, causing a stall in the second capture device. Also, the vimc patch https://patchwork.kernel.org/patch/10948833/ won't be required with this patchset. This patchset was tested on rkisp1 and vimc drivers. Other cleanup might be possible (but I won't add in this patchset as I don't have the hw to test): https://git.linuxtv.org/media_tree.git/tree/drivers/media/platform/qcom/camss/camss-video.c#n430 https://git.linuxtv.org/media_tree.git/tree/drivers/media/platform/omap3isp/isp.c#n697 https://git.linuxtv.org/media_tree.git/tree/drivers/media/platform/stm32/stm32-dcmi.c#n680 https://git.linuxtv.org/media_tree.git/tree/drivers/media/platform/xilinx/xilinx-dma.c#n97 Changes in V3: ==================== Following up Niklas' comments in V2 https://patchwork.kernel.org/patch/11473681/#23270823 * I removed the limitation in topologies with entities with multiple enabled links to its sink pads in the topology. Now it enables all subdevs in the pipeline that have an enabled link going from sink to source while walking from the video device, so it can be also useful for rcar-vin driver. To implement this, I added back in the series the patch from v1: "media: mc-entity.c: add media_graph_walk_next_stream()" * "size" was renamed to "max_size" in function v4l2_pipeline_subdevs_get() to reflect the maximum number of elements that can fit in the subdevs array, with proper documentation. * v4l2_pipeline_subdevs_get() returns a negative number for error, instead of returning 0 and printing a warning. * I also add if defined(CONFIG_MEDIA_CONTROLLER) around helpers to avoid compiling errors. Overview of patches in V3: -------------------------- Patch 1/4 adds a new iterator function to follow links from sink to source only. Path 2/4 adds the helpers in v4l2-common.c, allowing nested calls by adding stream_count in the subdevice struct. Patch 3/4 cleanup rkisp1 driver to use the helpers. Patch 4/4 cleanup vimc driver to use the helpers. Changes in V2: ==================== The first version was calling the s_stream() callbacks from sensor to capture. This was generating errors in the Scarlet Chromebook, when the sensor was being enabled before the ISP. It make sense to enable subdevices from capture to sensor instead (which is what most drivers do already). This v2 drops the changes from mc-entity.c, and re-implement helpers in v4l2-common.c Overview of patches in V2: -------------------------- Path 1/3 adds the helpers in v4l2-common.c, allowing nested calls by adding stream_count in the subdevice struct. Patch 2/3 cleanup rkisp1 driver to use the helpers. Patch 3/3 cleanup vimc driver to use the helpers. Helen Koike (4): media: mc-entity.c: add media_graph_walk_next_stream() media: v4l2-common: add helper functions to call s_stream() callbacks media: staging: rkisp1: use v4l2_pipeline_stream_{enable,disable} helpers media: vimc: use v4l2_pipeline_stream_{enable,disable} helpers drivers/media/mc/mc-entity.c | 34 ++++- .../media/test_drivers/vimc/vimc-capture.c | 28 ++-- .../media/test_drivers/vimc/vimc-streamer.c | 49 +------ drivers/media/v4l2-core/v4l2-common.c | 125 ++++++++++++++++++ drivers/staging/media/rkisp1/rkisp1-capture.c | 76 +---------- include/media/media-entity.h | 15 +++ include/media/v4l2-common.h | 43 ++++++ include/media/v4l2-subdev.h | 2 + 8 files changed, 242 insertions(+), 130 deletions(-) -- 2.26.0