Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21754255F4F for ; Thu, 22 May 2025 21:31:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747949480; cv=none; b=QXlq0QAYyhjSj8qBx8jksKK8ekwpMNS/iKbA+g/yZywNhwTX5XJsCNNR2x+nwHkvW3+rbCZowfGMCBz02mBueCau3QhdB9UAl96Z/CTiK6HIXN0+qhDoDB/+k3RbEho6WL0X0AGbTPqTvt5prgGtI7NLrso0iPzOCoh8+dKdESY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747949480; c=relaxed/simple; bh=VEYA4G1pTJzoUFND8ROQiMzxZewm4J9o9nm2XFPXjr4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XRBt93JShKPHx819/9tkSY+Aie6vGsXkA33hymqYDgaLuaYh9EIlwLI09pZNRtxMVMXPC63afaQUwmdlmaLtyVQCU8DkzDLQk+RDIVUkh0sj4q7bSh4hASC4d7hvMcF+eDx9ghdaMlbVWm6iisJGDtXlv5rwF8kXNetO9y/XZLU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=aE2yuxZl; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aE2yuxZl" Received: from [192.168.0.43] (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 130B1605; Thu, 22 May 2025 23:30:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1747949455; bh=VEYA4G1pTJzoUFND8ROQiMzxZewm4J9o9nm2XFPXjr4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aE2yuxZlv+VKPRnXPJ5ZmqEdyg24c1Hnl48U3xt825fAfN3TZY18K4hT+xv7LqC3Q l0Jq0d1ba+7fzycMJLTcVcmSf66enezaZrps91W4qW5wgIU/434EeHTpu3RoBFKt0S sOecL10w7YU+hfIoZO6AlJKZh12TBHSC9P5GDhdE= Message-ID: <378e058d-01d8-43de-a61c-76f1b431e115@ideasonboard.com> Date: Thu, 22 May 2025 22:31:14 +0100 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] media: mc: entity: Add pipeline_started/stopped ops To: Jacopo Mondi Cc: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, mchehab@kernel.org References: <20250519140403.443915-1-dan.scally@ideasonboard.com> <20250519140403.443915-2-dan.scally@ideasonboard.com> Content-Language: en-US From: Dan Scally Autocrypt: addr=dan.scally@ideasonboard.com; keydata= xsFNBGLydlEBEADa5O2s0AbUguprfvXOQun/0a8y2Vk6BqkQALgeD6KnXSWwaoCULp18etYW B31bfgrdphXQ5kUQibB0ADK8DERB4wrzrUb5CMxLBFE7mQty+v5NsP0OFNK9XTaAOcmD+Ove eIjYvqurAaro91jrRVrS1gBRxIFqyPgNvwwL+alMZhn3/2jU2uvBmuRrgnc/e9cHKiuT3Dtq MHGPKL2m+plk+7tj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3p3gvfM Res4fGX94Ji599uLNrPoxKyaytC4R6BTxVriTJjWK8mbo9jZIRM4vkwkZZ2bu98EweSucxbp vjESsvMXGgxniqV/RQ/3T7LABYRoIUutARYq58p5HwSP0frF0fdFHYdTa2g7MYZl1ur2JzOC FHRpGadlNzKDE3fEdoMobxHB3Lm6FDml5GyBAA8+dQYVI0oDwJ3gpZPZ0J5Vx9RbqXe8RDuR du90hvCJkq7/tzSQ0GeD3BwXb9/R/A4dVXhaDd91Q1qQXidI+2jwhx8iqiYxbT+DoAUkQRQy xBtoCM1CxH7u45URUgD//fxYr3D4B1SlonA6vdaEdHZOGwECnDpTxecENMbz/Bx7qfrmd901 D+N9SjIwrbVhhSyUXYnSUb8F+9g2RDY42Sk7GcYxIeON4VzKqWM7hpkXZ47pkK0YodO+dRKM yMcoUWrTK0Uz6UzUGKoJVbxmSW/EJLEGoI5p3NWxWtScEVv8mO49gqQdrRIOheZycDmHnItt 9Qjv00uFhEwv2YfiyGk6iGF2W40s2pH2t6oeuGgmiZ7g6d0MEK8Ql/4zPItvr1c1rpwpXUC1 u1kQWgtnNjFHX3KiYdqjcZeRBiry1X0zY+4Y24wUU0KsEewJwjhmCKAsju1RpdlPg2kC In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Jacopo On 21/05/2025 16:18, Jacopo Mondi wrote: > Hi Dan > > On Mon, May 19, 2025 at 03:04:01PM +0100, Daniel Scally wrote: >> Add two new members to struct media_entity_operations, along with new >> functions in media-entity.c to traverse a media pipeline and call the >> new operations. The new functions are intended to be used to signal >> to a media pipeline that it has fully started, with the entity ops >> allowing drivers to define some action to be taken when those >> conditions are met. >> >> The combination of the new functions and operations allows drivers >> which are part of a multi-driver pipeline to delay actually starting >> streaming until all of the conditions for streaming succcessfully are >> met across all drivers. > Maybe s/succcessfully are/are successfully/ > > Or was this (the three 'c' apart) intentional ? It was intentional as-is but I think it reads just fine the other way round too; happy to change to that. > >> Signed-off-by: Daniel Scally >> --- >> drivers/media/mc/mc-entity.c | 45 ++++++++++++++++++++++++++++++++++++ >> include/media/media-entity.h | 24 +++++++++++++++++++ >> 2 files changed, 69 insertions(+) >> >> diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c >> index 045590905582..e36b1710669d 100644 >> --- a/drivers/media/mc/mc-entity.c >> +++ b/drivers/media/mc/mc-entity.c >> @@ -1053,6 +1053,51 @@ __media_pipeline_entity_iter_next(struct media_pipeline *pipe, >> } >> EXPORT_SYMBOL_GPL(__media_pipeline_entity_iter_next); >> >> +int media_pipeline_started(struct media_pipeline *pipe) >> +{ >> + struct media_pipeline_entity_iter iter; >> + struct media_entity *entity; >> + int ret; >> + >> + ret = media_pipeline_entity_iter_init(pipe, &iter); >> + if (ret) >> + return ret; >> + >> + media_pipeline_for_each_entity(pipe, &iter, entity) { >> + ret = media_entity_call(entity, pipeline_started); >> + if (ret && ret != -ENOIOCTLCMD) >> + goto err_notify_stopped; >> + } >> + >> + media_pipeline_entity_iter_cleanup(&iter); >> + >> + return ret == -ENOIOCTLCMD ? 0 : ret; > Shouldn't you just return 0 ? If a ret < 0 is encoutered in the loop > we just to the below label Oh yeah; good point. > >> + >> +err_notify_stopped: >> + media_pipeline_stopped(pipe); > Do you need to media_pipeline_entity_iter_cleanup() ? Yes - thanks. > >> + return ret; >> +} >> +EXPORT_SYMBOL_GPL(media_pipeline_started); >> + >> +int media_pipeline_stopped(struct media_pipeline *pipe) >> +{ >> + struct media_pipeline_entity_iter iter; >> + struct media_entity *entity; >> + int ret; >> + >> + ret = media_pipeline_entity_iter_init(pipe, &iter); >> + if (ret) >> + return ret; >> + >> + media_pipeline_for_each_entity(pipe, &iter, entity) >> + media_entity_call(entity, pipeline_stopped); >> + >> + media_pipeline_entity_iter_cleanup(&iter); >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_GPL(media_pipeline_stopped); >> + >> /* ----------------------------------------------------------------------------- >> * Links management >> */ >> diff --git a/include/media/media-entity.h b/include/media/media-entity.h >> index 64cf590b1134..e858326b95cb 100644 >> --- a/include/media/media-entity.h >> +++ b/include/media/media-entity.h >> @@ -269,6 +269,10 @@ struct media_pad { >> * media_entity_has_pad_interdep(). >> * Optional: If the operation isn't implemented all pads >> * will be considered as interdependent. >> + * @pipeline_started: Notify this entity that the pipeline it is a part of has >> + * been started >> + * @pipeline_stopped: Notify this entity that the pipeline it is a part of has >> + * been stopped >> * >> * .. note:: >> * >> @@ -284,6 +288,8 @@ struct media_entity_operations { >> int (*link_validate)(struct media_link *link); >> bool (*has_pad_interdep)(struct media_entity *entity, unsigned int pad0, >> unsigned int pad1); >> + int (*pipeline_started)(struct media_entity *entity); >> + void (*pipeline_stopped)(struct media_entity *entity); >> }; >> >> /** >> @@ -1261,6 +1267,24 @@ __media_pipeline_entity_iter_next(struct media_pipeline *pipe, >> entity != NULL; \ >> entity = __media_pipeline_entity_iter_next((pipe), iter, entity)) >> >> +/** >> + * media_pipeline_started - Inform entities in a pipeline that it has started >> + * @pipe: The pipeline >> + * >> + * Iterate on all entities in a media pipeline and call their pipeline_started >> + * member of media_entity_operations. >> + */ >> +int media_pipeline_started(struct media_pipeline *pipe); >> + >> +/** >> + * media_pipeline_stopped - Inform entities in a pipeline that it has stopped >> + * @pipe: The pipeline >> + * >> + * Iterate on all entities in a media pipeline and call their pipeline_stopped >> + * member of media_entity_operations. >> + */ >> +int media_pipeline_stopped(struct media_pipeline *pipe); >> + > All good, but I don't see these operations being used at all in this > series ? Ah, yeah...organisational deficiency on my part; it's used by the ISP and IVC drivers in the series' which are based on this one, and it's kinda related in that it's required to get the multiple drivers registering video devices into the same media device to play nicely together, so I bundled them into the same series. I could send it alone, or update the series cover message to make more clear it's encompassing a few things? > >> /** >> * media_pipeline_alloc_start - Mark a pipeline as streaming >> * @pad: Starting pad >> -- >> 2.34.1 >> >>