linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xia Jiang <xia.jiang@mediatek.com>
To: Tomasz Figa <tfiga@chromium.org>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	Rick Chang <rick.chang@mediatek.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>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	<srv_heupstream@mediatek.com>, <senozhatsky@chromium.org>,
	<mojahsu@chromium.org>, <drinkcat@chromium.org>,
	<maoguang.meng@mediatek.com>
Subject: Re: [PATCH v10 22/28] media: platform: Change the call functions of getting/enable/disable the jpeg's clock
Date: Fri, 31 Jul 2020 11:20:02 +0800	[thread overview]
Message-ID: <1596165602.17247.10.camel@mhfsdcap03> (raw)
In-Reply-To: <20200730163419.GA3779380@chromium.org>

On Thu, 2020-07-30 at 16:34 +0000, Tomasz Figa wrote:
> Hi Xia,
> 
> On Thu, Jul 23, 2020 at 11:04:45AM +0800, Xia Jiang wrote:
> > Use the generic of_property_* helpers to get the clock_nums and clocks
> > from device tree.
> > Use the generic clk_bulk_* helpers to enable and disable clocks.
> > 
> > Signed-off-by: Xia Jiang <xia.jiang@mediatek.com>
> > ---
> > v10: new add patch
> > ---
> >  .../media/platform/mtk-jpeg/mtk_jpeg_core.c   | 47 +++++++++++++++----
> >  .../media/platform/mtk-jpeg/mtk_jpeg_core.h   |  8 ++--
> >  2 files changed, 42 insertions(+), 13 deletions(-)
> > 
> 
> Thank you for the patch. Please see my comments inline.
> 
> > diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> > index 7881e9c93df7..921ed21f7db3 100644
> > --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> > +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> > @@ -783,14 +783,15 @@ static void mtk_jpeg_clk_on(struct mtk_jpeg_dev *jpeg)
> >  	ret = mtk_smi_larb_get(jpeg->larb);
> >  	if (ret)
> >  		dev_err(jpeg->dev, "mtk_smi_larb_get larbvdec fail %d\n", ret);
> > -	clk_prepare_enable(jpeg->clk_jdec_smi);
> > -	clk_prepare_enable(jpeg->clk_jdec);
> > +
> > +	ret = clk_bulk_prepare_enable(jpeg->num_clks, jpeg->clks);
> > +	if (ret)
> > +		dev_err(jpeg->dev, "Failed to open jpeg clk: %d\n", ret);
> >  }
> >  
> >  static void mtk_jpeg_clk_off(struct mtk_jpeg_dev *jpeg)
> >  {
> > -	clk_disable_unprepare(jpeg->clk_jdec);
> > -	clk_disable_unprepare(jpeg->clk_jdec_smi);
> > +	clk_bulk_disable_unprepare(jpeg->num_clks, jpeg->clks);
> >  	mtk_smi_larb_put(jpeg->larb);
> >  }
> >  
> > @@ -939,6 +940,7 @@ static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg)
> >  {
> >  	struct device_node *node;
> >  	struct platform_device *pdev;
> > +	int ret, i;
> >  
> >  	node = of_parse_phandle(jpeg->dev->of_node, "mediatek,larb", 0);
> >  	if (!node)
> > @@ -952,12 +954,39 @@ static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg)
> >  
> >  	jpeg->larb = &pdev->dev;
> >  
> > -	jpeg->clk_jdec = devm_clk_get(jpeg->dev, "jpgdec");
> > -	if (IS_ERR(jpeg->clk_jdec))
> > -		return PTR_ERR(jpeg->clk_jdec);
> > +	jpeg->num_clks =
> > +		of_property_count_strings(jpeg->dev->of_node, "clock-names");
> > +
> > +	if (jpeg->num_clks > 0) {
> > +		jpeg->clks = devm_kcalloc(jpeg->dev, jpeg->num_clks,
> > +					  sizeof(struct clk_bulk_data),
> > +					  GFP_KERNEL);
> > +		if (!jpeg->clks)
> > +			return -ENOMEM;
> > +	} else {
> > +		dev_err(&pdev->dev, "Failed to get jpeg clock count\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	for (i = 0; i < jpeg->num_clks; i++) {
> > +		ret = of_property_read_string_index(jpeg->dev->of_node,
> > +						    "clock-names", i,
> > +						    &jpeg->clks->id);
> 
> The names of the clocks must be explicitly specified in the driver, as per
> the DT bindings.
Dear Tomasz,

Thank you for your reply.
You mean that I should keep the v9 version about names of the clocks in
the match data.
The v10 version about the names of the clocks follows the upstreamed
mtk_venc/vdec.I think that this method is more generic. For example,when
other project has more clocks, we can get the names of clocks from dtsi
without changing the driver code.
What about your further opinion? 

Best Regards,
Xia Jiang
> 
> Best regards,
> Tomasz


  reply	other threads:[~2020-07-31  3:21 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23  3:04 [PATCH v10 00/28] Add support for mt2701 JPEG ENC support Xia Jiang
2020-07-23  3:04 ` [PATCH v10 01/28] media: platform: Improve subscribe event flow for bug fixing Xia Jiang
2020-07-23  3:04 ` [PATCH v10 02/28] media: platform: Improve queue set up " Xia Jiang
2020-07-23  3:04 ` [PATCH v10 03/28] media: platform: Improve getting and requesting irq " Xia Jiang
2020-07-23  3:04 ` [PATCH v10 04/28] media: platform: Change the fixed device node number to unfixed value Xia Jiang
2020-07-23  3:04 ` [PATCH v10 05/28] media: platform: Improve power on and power off flow Xia Jiang
2020-07-23  3:04 ` [PATCH v10 06/28] media: platform: Delete the resetting hardware flow in the system PM ops Xia Jiang
2020-07-23  3:04 ` [PATCH v10 07/28] media: platform: Improve the implementation of " Xia Jiang
2020-07-23  3:04 ` [PATCH v10 08/28] media: platform: Add mechanism to handle jpeg hardware's locking up Xia Jiang
2020-07-23  3:04 ` [PATCH v10 09/28] media: platform: Cancel the last frame handling flow Xia Jiang
2020-07-23  3:04 ` [PATCH v10 10/28] media: platform: Delete zeroing the reserved fields Xia Jiang
2020-07-23  3:04 ` [PATCH v10 11/28] media: platform: Stylistic changes for improving code quality Xia Jiang
2020-07-23  3:04 ` [PATCH v10 12/28] media: platform: Use generic rounding helpers Xia Jiang
2020-07-23  3:04 ` [PATCH v10 13/28] media: platform: Change MTK_JPEG_COMP_MAX macro definition location Xia Jiang
2020-07-23  3:04 ` [PATCH v10 14/28] media: platform: Delete redundant code and add annotation for an enum Xia Jiang
2020-07-23  3:04 ` [PATCH v10 15/28] media: platform: Delete vidioc_s_selection ioctl of jpeg dec Xia Jiang
2020-07-23  3:04 ` [PATCH v10 16/28] media: platform: Change the maximum width and height supported by JPEG dec Xia Jiang
2020-07-23  3:04 ` [PATCH v10 17/28] media: platform: Refactor mtk_jpeg_try_fmt_mplane() Xia Jiang
2020-07-23  3:04 ` [PATCH v10 18/28] media: platform: Refactor mtk_jpeg_find_format() Xia Jiang
2020-07-23  3:04 ` [PATCH v10 19/28] media: platform: Redefinition of mtk_jpeg_q_data structure Xia Jiang
2020-07-23  3:04 ` [PATCH v10 20/28] media: platform: Change the colorspace of jpeg to the fixed value Xia Jiang
2020-07-23  3:04 ` [PATCH v10 21/28] media: platform: Refactor mtk_jpeg_set_default_params() Xia Jiang
2020-07-23  3:04 ` [PATCH v10 22/28] media: platform: Change the call functions of getting/enable/disable the jpeg's clock Xia Jiang
2020-07-30 16:34   ` Tomasz Figa
2020-07-31  3:20     ` Xia Jiang [this message]
2020-07-31 12:49       ` Tomasz Figa
2020-07-23  3:04 ` [PATCH v10 23/28] media: dt-bindings: Add jpeg enc device tree node document Xia Jiang
2020-07-23  3:04 ` [PATCH v10 24/28] arm: dts: mt2701: Add jpeg enc device tree node Xia Jiang
2020-07-23  3:04 ` [PATCH v10 25/28] media: platform: Rename jpeg dec file name Xia Jiang
2020-07-23  3:04 ` [PATCH v10 26/28] media: platform: Rename existing functions/defines/variables Xia Jiang
2020-07-23  3:04 ` [PATCH v10 27/28] media: platform: Using the variant structure to contain the varability between dec and enc Xia Jiang
2020-07-23  3:04 ` [PATCH v10 28/28] media: platform: Add jpeg enc feature Xia Jiang
2020-07-30 16:40 ` [PATCH v10 00/28] Add support for mt2701 JPEG ENC support Tomasz Figa

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=1596165602.17247.10.camel@mhfsdcap03 \
    --to=xia.jiang@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=drinkcat@chromium.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --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=m.szyprowski@samsung.com \
    --cc=maoguang.meng@mediatek.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab+samsung@kernel.org \
    --cc=mojahsu@chromium.org \
    --cc=rick.chang@mediatek.com \
    --cc=robh+dt@kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=srv_heupstream@mediatek.com \
    --cc=tfiga@chromium.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;
as well as URLs for NNTP newsgroup(s).