Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Nas Chung <nas.chung@chipsnmedia.com>
Cc: mchehab@kernel.org, hverkuil@kernel.org, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, Frank.Li@nxp.com,
	s.hauer@pengutronix.de, linux-media@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	festevam@gmail.com, kernel@pengutronix.de,
	nicolas.dufresne@collabora.com, ming.qian@oss.nxp.com,
	marek.vasut@mailbox.org, jackson.lee@chipsnmedia.com,
	lafley.kim@chipsnmedia.com
Subject: Re: [PATCH v8 02/11] media: chips-media: wave6: Add Wave6 control driver
Date: Thu, 19 Nov 2026 14:07:55 -0600	[thread overview]
Message-ID: <av9XG97eKQ1gZCFb@SMW015318> (raw)
In-Reply-To: <6b00047b748267a2ff4e18ccbfd573ea92166d34.1795075580.git.nas.chung@chipsnmedia.com>

On Thu, Nov 19, 2026 at 05:59:56PM +0900, Nas Chung wrote:
> Add the control driver for the Chips&Media Wave6 video codec IP.
>
> The hardware contains one control register region and four interface
> register regions for a shared video processing engine.
>
> This driver handles the control region and manages shared resources such
> as firmware loading, firmware memory allocation, and coordination required
> by the interface register regions.
>
> It also instantiates and coordinates with the `wave6-core` child devices
> for firmware and power state management.
>
> Tested-by: Ming Qian <ming.qian@oss.nxp.com>
> Tested-by: Marek Vasut <marek.vasut@mailbox.org>
> Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
> ---
...
> +
> +static inline int wave6_vdi_alloc_dma(struct device *dev, struct vpu_buf *vb)
> +{
> +	void *vaddr;
> +	dma_addr_t daddr;

Nit try keep revise christmas order, check others

dma_addr_t daddr;
void *vaddr;

> +
> +	if (!vb || !vb->size)
> +		return -EINVAL;
> +
> +	vaddr = dma_alloc_coherent(dev, vb->size, &daddr, GFP_KERNEL);
> +	if (!vaddr)
> +		return -ENOMEM;
> +
> +	vb->vaddr = vaddr;
> +	vb->daddr = daddr;
> +	vb->dev = dev;
> +
> +	return 0;
> +}
> +
...
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/clk.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/property.h>
> +#include <linux/of_irq.h>
> +#include <linux/firmware.h>
> +#include <linux/interrupt.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/pm_domain.h>
> +#include <linux/dma-mapping.h>
> +#include <linux/iopoll.h>
> +#include <linux/genalloc.h>

order by alpabet.

> +
> +#include "wave6-vpuconfig.h"
> +#include "wave6-regdefine.h"
> +#include "wave6-vpu.h"
> +
> +static const struct wave6_vpu_resource wave633c_data = {
> +	.fw_name = "cnm/wave633c_imx9_codec_fw.bin",
> +	/* For HEVC, AVC, 4096x4096, 8bit */
> +	.sram_size = 0x14800,
> +};
> +
...
> +
> +static u32 wave6_vpu_get_code_buf_size(struct wave6_vpu_device *vpu)
> +{
> +	return min_t(u32, vpu->code_buf.size, W6_MAX_CODE_BUF_SIZE);

now use min()

> +}
> +
...
> +
> +static int wave6_vpu_probe(struct platform_device *pdev)
> +{
> +	struct device_node *np;
> +	struct wave6_vpu_device *vpu;
> +	const struct wave6_vpu_resource *res;
> +	int ret;
> +
> +	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "failed to set DMA mask: %d\n", ret);
> +		return ret;
> +	}

Needn't check when mask > 32, if check,

	return dev_err_probe()

> +
> +	res = device_get_match_data(&pdev->dev);
> +	if (!res)
> +		return -ENODEV;
> +
...
> +
> +	wave6_vpu_allocate_work_buffers(vpu);
> +
> +	pm_runtime_enable(&pdev->dev);

devm_pm_runtime_enable();

you have not enable clock here, so you need select PM at Kconfig, otherwise
if !CONFIG_PM, other register access will be hang because stub do nothing
of runtime pm when !CONFIG_PM

> +
> +	init_completion(&vpu->fw_done);
> +	ret = firmware_request_nowait_nowarn(THIS_MODULE,
> +					     vpu->res->fw_name,
> +					     &pdev->dev,
> +					     GFP_KERNEL,
> +					     vpu,
> +					     wave6_vpu_load_firmware);
> +	if (ret) {
> +		dev_err(&pdev->dev, "request firmware fail, ret = %d\n", ret);
> +		goto error;
> +	}
> +
> +	return 0;
> +
> +error:
> +	wave6_vpu_release(vpu);
> +	pm_runtime_disable(&pdev->dev);
> +error_detach_pm_domains:
> +	wave6_vpu_detach_pm_domains(vpu);

use devm_add_action_or_reset() to avoid goto in probe()

> +
> +	return ret;
> +}
> +
...
> +
> +module_platform_driver(wave6_vpu_driver);
> +MODULE_DESCRIPTION("chips&media Wave6 VPU driver");
> +MODULE_AUTHOR("CHIPS&MEDIA INC");
> +MODULE_FIRMWARE("cnm/wave633c_imx9_codec_fw.bin");
> +MODULE_LICENSE("Dual BSD/GPL");
> diff --git a/drivers/media/platform/chips-media/wave6/wave6-vpu.h b/drivers/media/platform/chips-media/wave6/wave6-vpu.h
> new file mode 100644
> index 000000000000..96d67e931e71
> --- /dev/null
> +++ b/drivers/media/platform/chips-media/wave6/wave6-vpu.h
> @@ -0,0 +1,137 @@
> +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
> +/*
> + * Wave6 series multi-standard codec IP - wave6 driver
> + *
> + * Copyright (C) 2026 CHIPS&MEDIA INC
> + */
> +
> +#ifndef __WAVE6_VPU_H__
> +#define __WAVE6_VPU_H__
> +
> +#include <linux/completion.h>
> +#include <linux/device.h>
> +
> +#include "wave6-vpuconfig.h"
> +#include "wave6-vdi.h"
> +
> +#define WAVE6_VPU_PLATFORM_DRIVER_NAME "wave6-vpu"
> +#define WAVE6_VPU_CORE_PLATFORM_DRIVER_NAME "wave6-vpu-core"

If only use once, needn't define macro.

> +
> +struct wave6_vpu_device;
> +
> +/**
> + * enum wave6_vpu_state - VPU states
> + * @WAVE6_VPU_STATE_OFF:	VPU is powered off
> + * @WAVE6_VPU_STATE_PREPARE:	VPU is booting
> + * @WAVE6_VPU_STATE_ON:		VPU is running
> + * @WAVE6_VPU_STATE_SLEEP:	VPU is in a sleep mode
> + */
...
> +
> +#define W6_VPU_MAX_NUM_CORE		4
> +#define MAX_NUM_INSTANCE		32
> +
> +#define W6_VPU_POLL_DELAY_US		10
> +#define W6_VPU_POLL_TIMEOUT		300000

Need unit surfix

Frank

> +
> +#define W6_MAX_REMAP_PAGE_SIZE		(1024 * 1024)
> +#define W6_MAX_CODE_BUF_SIZE		(4 * 1024 * 1024)
> +#define W6_CODE_BUF_SIZE		(1 * 1024 * 1024)
> +#define W6_EXTRA_CODE_BUF_SIZE		(256 * 1024)
> +#define W637DEC_WORKBUF_SIZE_FOR_CQ	(3 * 512 * 1024)
> +
> +static inline bool wave6_is_product_w_series(u32 code)
> +{
> +	return code == WAVE617_CODE || code == WAVE627_CODE ||
> +	       code == WAVE633_CODE || code == WAVE637_CODE ||
> +	       code == WAVE663_CODE || code == WAVE677_CODE;
> +}
> +
> +#endif /* __WAVE6_VPUCONFIG_H__ */
> --
> 2.41.0.windows.3
>
>

  parent reply	other threads:[~2026-11-19 20:08 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  8:59 [PATCH v8 00/11] Add support for Wave6 video codec driver Nas Chung
2026-11-19  8:59 ` [PATCH v8 01/11] dt-bindings: media: nxp: Add Wave6 video codec device Nas Chung
2026-11-19  8:59 ` [PATCH v8 02/11] media: chips-media: wave6: Add Wave6 control driver Nas Chung
2026-11-19  9:26   ` sashiko-bot
2026-11-19 19:36     ` Frank Li
2026-11-19 20:07   ` Frank Li [this message]
2026-11-19  8:59 ` [PATCH v8 03/11] media: chips-media: wave6: Add Wave6 core driver Nas Chung
2026-11-19  9:32   ` sashiko-bot
2026-11-19 20:27   ` Frank Li
2026-11-19  8:59 ` [PATCH v8 04/11] media: chips-media: wave6: Add Wave6 decoder firmware interface Nas Chung
2026-11-19  9:22   ` sashiko-bot
2026-11-19 20:37   ` Frank Li
2026-11-19  8:59 ` [PATCH v8 05/11] media: chips-media: wave6: Add Wave6 m2m decoder Nas Chung
2026-11-19  9:31   ` sashiko-bot
2026-11-19  9:00 ` [PATCH v8 06/11] media: chips-media: wave6: Add Wave6 encoder firmware interface Nas Chung
2026-11-19  9:10   ` sashiko-bot
2026-11-19  9:00 ` [PATCH v8 07/11] media: chips-media: wave6: Add Wave6 m2m encoder Nas Chung
2026-11-19  9:35   ` sashiko-bot
2026-11-19  9:00 ` [PATCH v8 08/11] media: chips-media: wave6: Add trace and debugfs Nas Chung
2026-11-19  9:14   ` sashiko-bot
2026-11-19  9:00 ` [PATCH v8 09/11] media: chips-media: wave6: Add performance profiling Nas Chung
2026-11-19  9:20   ` sashiko-bot
2026-11-19 20:56   ` Frank Li
2026-11-19  9:00 ` [PATCH v8 10/11] media: chips-media: wave6: Add Wave6 thermal cooling device Nas Chung
2026-11-19  9:21   ` sashiko-bot
2026-11-19 21:03   ` Frank Li
2026-11-19  9:00 ` [PATCH v8 11/11] arm64: dts: freescale: imx95: Add video codec node Nas Chung
2026-11-19  9:37   ` sashiko-bot
2026-11-19 21:05   ` Frank Li

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=av9XG97eKQ1gZCFb@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=hverkuil@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=jackson.lee@chipsnmedia.com \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=lafley.kim@chipsnmedia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=marek.vasut@mailbox.org \
    --cc=mchehab@kernel.org \
    --cc=ming.qian@oss.nxp.com \
    --cc=nas.chung@chipsnmedia.com \
    --cc=nicolas.dufresne@collabora.com \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    /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