Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	Vikash Garodia <quic_vgarodia@quicinc.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: quic_renjiang@quicinc.com, quic_vnagar@quicinc.com,
	quic_dikshita@quicinc.com, konradybcio@kernel.org,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Stanimir Varbanov <stanimir.varbanov@linaro.org>
Subject: Re: [PATCH v5 1/3] media: venus: Add support for static video encoder/decoder declarations
Date: Sat, 28 Dec 2024 15:33:38 +0200	[thread overview]
Message-ID: <504ff336-3b11-4331-b2b6-86289b17ffd3@gmail.com> (raw)
In-Reply-To: <20241209-media-staging-24-11-25-rb3-hw-compat-string-v5-1-ef7e5f85f302@linaro.org>

Hi Bryan,

Thank for your work !

On 9.12.24 г. 13:52 ч., Bryan O'Donoghue wrote:
> Add resource structure data and probe() logic to support static
> declarations of encoder and decoder.
> 
> Right now we rely on video encoder/decoder selection happening in the dtb
> but, this goes against the remit of device tree which is supposed to
> describe hardware, not select functional logic in Linux drivers.
> 
> Provide two strings in the venus resource structure enc_nodename and
> dec_nodename.
> 
> When set the venus driver will create an OF entry in-memory consistent
> with:
> 
> dec_nodename {
>      compat = "video-decoder";
> };
> 
> and/or
> 
> enc_nodename {
>      compat = "video-encoder";
> };
> 
> This will allow us to reuse the existing driver scheme of relying on compat
> names maintaining compatibility with old dtb files.
> 
> dec_nodename can be "video-decoder" or "video0"
> enc_nodename can be "video-encoder" or "video1"
> 
> This change relies on of_changeset() API as a result select OF_DYNAMIC will
> be added to venus/Kconfig
> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>   drivers/media/platform/qcom/venus/Kconfig |  1 +
>   drivers/media/platform/qcom/venus/core.c  | 94 ++++++++++++++++++++++++++++++-
>   drivers/media/platform/qcom/venus/core.h  |  4 ++
>   3 files changed, 98 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/Kconfig b/drivers/media/platform/qcom/venus/Kconfig
> index bfd50e8f34219db8a1de7960d7ea93b20db2982a..bc2e410b29cb415a36540a4f98709eae44f4ec35 100644
> --- a/drivers/media/platform/qcom/venus/Kconfig
> +++ b/drivers/media/platform/qcom/venus/Kconfig
> @@ -3,6 +3,7 @@ config VIDEO_QCOM_VENUS
>   	depends on V4L_MEM2MEM_DRIVERS
>   	depends on VIDEO_DEV && QCOM_SMEM
>   	depends on (ARCH_QCOM && IOMMU_DMA) || COMPILE_TEST
> +	select OF_DYNAMIC if ARCH_QCOM
>   	select QCOM_MDT_LOADER if ARCH_QCOM
>   	select QCOM_SCM
>   	select VIDEOBUF2_DMA_CONTIG
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index 4e26b18790537885a77d66c1917a4e7a146eaf57..88dfa9f240dc6d18a7f58dc06b1bf10274b7121e 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -286,6 +286,89 @@ static irqreturn_t venus_isr_thread(int irq, void *dev_id)
>   	return ret;
>   }
>   
> +#if defined(CONFIG_OF_DYNAMIC)
> +static int venus_add_video_core(struct venus_core *core, const char *node_name,
> +				const char *compat)
> +{
> +	struct of_changeset *ocs = core->ocs;
> +	struct device *dev = core->dev;
> +	struct device_node *np, *enp;
> +	int ret;
> +
> +	if (!node_name)
> +		return 0;
> +
> +	enp = of_find_node_by_name(dev->of_node, node_name);
> +	if (enp) {
> +		of_node_put(enp);
> +		return 0;
> +	}
> +
> +	np = of_changeset_create_node(ocs, dev->of_node, node_name);
> +	if (!np) {
> +		dev_err(dev, "Unable to create new node\n");
> +		return -ENODEV;
> +	}
> +
> +	ret = of_changeset_add_prop_string(ocs, np, "compatible", compat);
> +	if (ret)
> +		dev_err(dev, "unable to add %s\n", compat);
> +
> +	of_node_put(np);
> +
> +	return ret;
> +}
> +
> +static int venus_add_dynamic_nodes(struct venus_core *core)
> +{
> +	struct device *dev = core->dev;
> +	int ret;
> +
> +	core->ocs = kmalloc(sizeof(*core->ocs), GFP_KERNEL);
> +	if (!core->ocs)
> +		return -ENOMEM;
> +
> +	of_changeset_init(core->ocs);
> +
> +	ret = venus_add_video_core(core, core->res->dec_nodename, "venus-decoder");
> +	if (ret)
> +		goto err;
> +
> +	ret = venus_add_video_core(core, core->res->enc_nodename, "venus-encoder");
> +	if (ret)
> +		goto err;
> +
> +	ret = of_changeset_apply(core->ocs);
> +	if (ret) {
> +		dev_err(dev, "applying changeset fail ret %d\n", ret);
> +		goto err;
> +	}
> +
> +	return 0;
> +err:
> +	of_changeset_destroy(core->ocs);
> +	kfree(core->ocs);
> +	core->ocs = NULL;
> +	return ret;
> +}
> +
> +static void venus_remove_dynamic_nodes(struct venus_core *core)
> +{
> +	if (core->ocs) {
> +		of_changeset_revert(core->ocs);
> +		of_changeset_destroy(core->ocs);
> +		kfree(core->ocs);
> +	}
> +}
> +#else
> +static int venus_add_dynamic_nodes(struct venus_core *core)
> +{
> +	return 0;
> +}
> +
> +static void venus_remove_dynamic_nodes(struct venus_core *core) {}
> +#endif
> +
>   static int venus_probe(struct platform_device *pdev)
>   {
>   	struct device *dev = &pdev->dev;
> @@ -365,9 +448,14 @@ static int venus_probe(struct platform_device *pdev)
>   	if (ret < 0)
>   		goto err_runtime_disable;
>   
> +	if (core->res->dec_nodename || core->res->enc_nodename) {
> +		if (venus_add_dynamic_nodes(core))

It'd be good to pass the error code to the upper layer.

> +			goto err_runtime_disable;
> +	}
> +
>   	ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
>   	if (ret)
> -		goto err_runtime_disable;
> +		goto err_remove_dynamic_nodes;
>   
>   	ret = venus_firmware_init(core);
>   	if (ret)
> @@ -411,6 +499,8 @@ static int venus_probe(struct platform_device *pdev)
>   	venus_firmware_deinit(core);
>   err_of_depopulate:
>   	of_platform_depopulate(dev);
> +err_remove_dynamic_nodes:
> +	venus_remove_dynamic_nodes(core);
>   err_runtime_disable:
>   	pm_runtime_put_noidle(dev);
>   	pm_runtime_disable(dev);
> @@ -443,6 +533,8 @@ static void venus_remove(struct platform_device *pdev)
>   
>   	venus_firmware_deinit(core);
>   
> +	venus_remove_dynamic_nodes(core);
> +
>   	pm_runtime_put_sync(dev);
>   	pm_runtime_disable(dev);
>   
> diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
> index 27784fd7082c321222b23ca4b2902a04c49e19ca..306231b4f7d0201175974b4a42574f30d23e08f0 100644
> --- a/drivers/media/platform/qcom/venus/core.h
> +++ b/drivers/media/platform/qcom/venus/core.h
> @@ -90,6 +90,8 @@ struct venus_resources {
>   	u32 cp_nonpixel_start;
>   	u32 cp_nonpixel_size;
>   	const char *fwname;
> +	const char *enc_nodename;
> +	const char *dec_nodename;
>   };
>   
>   enum venus_fmt {
> @@ -171,6 +173,7 @@ struct venus_format {
>    * @root:	debugfs root directory
>    * @venus_ver:	the venus firmware version
>    * @dump_core:	a flag indicating that a core dump is required
> + * @ocs:	OF changeset pointer
>    */
>   struct venus_core {
>   	void __iomem *base;
> @@ -235,6 +238,7 @@ struct venus_core {
>   		u32 rev;
>   	} venus_ver;
>   	unsigned long dump_core;
> +	struct of_changeset *ocs;
>   };
>   
>   struct vdec_controls {
> 

-- 
regards,
Stan

  parent reply	other threads:[~2024-12-28 13:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09 11:52 [PATCH v5 0/3] media: venus: Provide support for selecting encoder/decoder from in-driver Bryan O'Donoghue
2024-12-09 11:52 ` [PATCH v5 1/3] media: venus: Add support for static video encoder/decoder declarations Bryan O'Donoghue
2024-12-18 10:44   ` Renjiang Han
2024-12-28 13:33   ` Stanimir Varbanov [this message]
2024-12-30 11:32     ` Bryan O'Donoghue
2024-12-09 11:52 ` [PATCH v5 2/3] media: venus: Populate video encoder/decoder nodename entries Bryan O'Donoghue
2024-12-13 20:00   ` Nicolas Dufresne
2024-12-13 22:46     ` Bryan O'Donoghue
2024-12-18 10:45   ` Renjiang Han
2024-12-09 11:52 ` [PATCH v5 3/3] media: dt-bindings: qcom-venus: Deprecate video-decoder and video-encoder where applicable Bryan O'Donoghue
2024-12-18 10:46   ` Renjiang Han
2024-12-18 12:38     ` Krzysztof Kozlowski
2024-12-19  2:45       ` Renjiang Han
2024-12-19  8:16         ` Krzysztof Kozlowski
2024-12-19  7:37 ` [PATCH v5 0/3] media: venus: Provide support for selecting encoder/decoder from in-driver Vikash Garodia
2024-12-19 12:07   ` Bryan O'Donoghue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=504ff336-3b11-4331-b2b6-86289b17ffd3@gmail.com \
    --to=stanimir.k.varbanov@gmail.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=quic_dikshita@quicinc.com \
    --cc=quic_renjiang@quicinc.com \
    --cc=quic_vgarodia@quicinc.com \
    --cc=quic_vnagar@quicinc.com \
    --cc=robh@kernel.org \
    --cc=stanimir.varbanov@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox