mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: CK Hu <ck.hu@mediatek.com>
To: Moudy Ho <moudy.ho@mediatek.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>,
	Rob Landley <rob@landley.net>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>,
	Alexandre Courbot <acourbot@chromium.org>, <tfiga@chromium.org>,
	<drinkcat@chromium.org>, <pihsun@chromium.org>,
	<hsinyi@google.com>,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>,
	daoyuan huang <daoyuan.huang@mediatek.com>,
	Ping-Hsun Wu <ping-hsun.wu@mediatek.com>,
	<allen-kh.cheng@mediatek.com>, <xiandong.wang@mediatek.com>,
	<randy.wu@mediatek.com>, <jason-jh.lin@mediatek.com>,
	<roy-cw.yeh@mediatek.com>, <river.cheng@mediatek.com>,
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	<cellopoint.kai@gmail.com>
Subject: Re: [PATCH v19 4/4] media: platform: mtk-mdp3: add Mediatek MDP3 driver
Date: Mon, 27 Jun 2022 11:51:00 +0800	[thread overview]
Message-ID: <61dfe9671e83970e806dfcea2af35eab2a83f273.camel@mediatek.com> (raw)
In-Reply-To: <20220624092359.11908-5-moudy.ho@mediatek.com>

Hi, Moudy:

On Fri, 2022-06-24 at 17:23 +0800, Moudy Ho wrote:
> This patch adds driver for Mediatek's Media Data Path ver.3 (MDP3).
> It provides the following functions:
>   color transform, format conversion, resize, crop, rotate, flip
>   and additional image quality enhancement.
> 
> The MDP3 driver is mainly used for Google Chromebook products to
> import the new architecture to set the HW settings as shown below:
>   User -> V4L2 framework
>     -> MDP3 driver -> SCP (setting calculations)
>       -> MDP3 driver -> CMDQ (GCE driver) -> HW
> 
> Each modules' related operation control is sited in mtk-mdp3-comp.c
> Each modules' register table is defined in file with "mdp_reg_"
> prefix
> GCE related API, operation control  sited in mtk-mdp3-cmdq.c
> V4L2 m2m device functions are implemented in mtk-mdp3-m2m.c
> Probe, power, suspend/resume, system level functions are defined in
> mtk-mdp3-core.c
> 

[snip]

> 
> +
> +int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)
> +{
> +	struct mdp_path *path = NULL;
> +	struct mdp_cmdq_cmd *cmd = NULL;
> +	struct mdp_comp *comps = NULL;
> +	struct device *dev = &mdp->pdev->dev;
> +	int i, ret;
> +
> +	atomic_inc(&mdp->job_count);
> +	if (atomic_read(&mdp->suspended)) {
> +		atomic_dec(&mdp->job_count);
> +		return -ECANCELED;
> +	}
> +
> +	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
> +	if (!cmd) {
> +		ret = -ENOMEM;
> +		goto err_cmdq_data;
> +	}
> +
> +	if (mdp_cmdq_pkt_create(mdp->cmdq_clt, &cmd->pkt, SZ_16K)) {
> +		ret = -ENOMEM;
> +		goto err_cmdq_data;
> +	}
> +
> +	comps = kcalloc(param->config->num_components, sizeof(*comps),
> +			GFP_KERNEL);
> +	if (!comps) {
> +		ret = -ENOMEM;
> +		goto err_cmdq_data;
> +	}
> +
> +	path = kzalloc(sizeof(*path), GFP_KERNEL);
> +	if (!path) {
> +		ret = -ENOMEM;
> +		goto err_cmdq_data;
> +	}
> +
> +	path->mdp_dev = mdp;
> +	path->config = param->config;
> +	path->param = param->param;
> +	for (i = 0; i < param->param->num_outputs; i++) {
> +		path->bounds[i].left = 0;
> +		path->bounds[i].top = 0;
> +		path->bounds[i].width =
> +			param->param->outputs[i].buffer.format.width;
> +		path->bounds[i].height =
> +			param->param->outputs[i].buffer.format.height;
> +		path->composes[i] = param->composes[i] ?
> +			param->composes[i] : &path->bounds[i];
> +	}
> +
> +	ret = mdp_path_ctx_init(mdp, path);
> +	if (ret) {
> +		dev_err(dev, "mdp_path_ctx_init error\n");
> +		goto err_cmdq_data;
> +	}
> +
> +	cmd->event = &mdp->event[0];
> +	ret = mdp_path_config(mdp, cmd, path);
> +	if (ret) {
> +		dev_err(dev, "mdp_path_config error\n");
> +		goto err_cmdq_data;
> +	}
> +	cmdq_pkt_finalize(&cmd->pkt);
> +
> +	for (i = 0; i < param->config->num_components; i++)
> +		memcpy(&comps[i], path->comps[i].comp,
> +		       sizeof(struct mdp_comp));
> +
> +	mdp->cmdq_clt->client.rx_callback = mdp_handle_cmdq_callback;
> +	cmd->mdp = mdp;
> +	cmd->user_cmdq_cb = param->cmdq_cb;
> +	cmd->user_cb_data = param->cb_data;
> +	cmd->comps = comps;
> +	cmd->num_comps = param->config->num_components;
> +	cmd->mdp_ctx = param->mdp_ctx;
> +
> +	mtk_mutex_prepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]);
> +	ret = mdp_comp_clocks_on(&mdp->pdev->dev, cmd->comps, cmd-
> >num_comps);
> +	if (ret) {
> +		dev_err(dev, "comp %d failed to enable clock!\n", ret);
> +		goto err_clock_off;
> +	}
> +
> +	dma_sync_single_for_device(mdp->cmdq_clt->chan->mbox->dev,
> +				   cmd->pkt.pa_base, cmd-
> >pkt.cmd_buf_size,
> +				   DMA_TO_DEVICE);
> +	ret = mbox_send_message(mdp->cmdq_clt->chan, &cmd->pkt);
> +	if (ret < 0) {
> +		dev_err(dev, "mbox send message fail %d!\n", ret);
> +		goto err_clock_off;
> +	}
> +	mbox_client_txdone(mdp->cmdq_clt->chan, 0);
> +
> +	kfree(path);
> +	return 0;
> +
> +err_clock_off:
> +	mtk_mutex_unprepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]);
> +	mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps,
> +			    cmd->num_comps);
> +err_cmdq_data:
> +	kfree(path);
> +	atomic_dec(&mdp->job_count);
> +	wake_up(&mdp->callback_wq);
> +	if (cmd->pkt.buf_size > 0)
> +		mdp_cmdq_pkt_destroy(&cmd->pkt);
> +	kfree(comps);
> +	kfree(cmd);
> +	return ret;
> +}

EXPORT_SYMBOL(mdp_cmdq_send);

So other kernel module could call this function.

Regards,
CK


      reply	other threads:[~2022-06-27  3:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24  9:23 [PATCH v19 0/4] media: mediatek: support mdp3 on mt8183 platform Moudy Ho
2022-06-24  9:23 ` [PATCH v19 1/4] dt-binding: mediatek: add bindings for MediaTek MDP3 components Moudy Ho
2022-06-24 10:29   ` AngeloGioacchino Del Regno
2022-06-24  9:23 ` [PATCH v19 2/4] dt-binding: mediatek: add bindings for MediaTek CCORR and WDMA Moudy Ho
2022-06-24 10:29   ` AngeloGioacchino Del Regno
2022-06-24  9:23 ` [PATCH v19 3/4] arm64: dts: mt8183: add Mediatek MDP3 nodes Moudy Ho
2022-06-24  9:23 ` [PATCH v19 4/4] media: platform: mtk-mdp3: add Mediatek MDP3 driver Moudy Ho
2022-06-27  3:51   ` CK Hu [this message]

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=61dfe9671e83970e806dfcea2af35eab2a83f273.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=acourbot@chromium.org \
    --cc=allen-kh.cheng@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=cellopoint.kai@gmail.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=daoyuan.huang@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=drinkcat@chromium.org \
    --cc=hsinyi@google.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jason-jh.lin@mediatek.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=moudy.ho@mediatek.com \
    --cc=pihsun@chromium.org \
    --cc=ping-hsun.wu@mediatek.com \
    --cc=randy.wu@mediatek.com \
    --cc=river.cheng@mediatek.com \
    --cc=rob@landley.net \
    --cc=robh+dt@kernel.org \
    --cc=roy-cw.yeh@mediatek.com \
    --cc=tfiga@chromium.org \
    --cc=xiandong.wang@mediatek.com \
    /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

all inboxes | Powered by JetHome®