linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Todor Tomov <todor.tomov@linaro.org>
Cc: mchehab@kernel.org, hans.verkuil@cisco.com,
	javier@osg.samsung.com, s.nawrocki@samsung.com,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v3 22/23] camss: Use optimal clock frequency rates
Date: Thu, 20 Jul 2017 18:23:13 +0300	[thread overview]
Message-ID: <20170720152313.joqfo7dqg5gbxrfl@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <1500287629-23703-23-git-send-email-todor.tomov@linaro.org>

Hi Todor,

On Mon, Jul 17, 2017 at 01:33:48PM +0300, Todor Tomov wrote:
> Use standard V4L2 control to get pixel clock rate from a sensor
> linked in the media controller pipeline. Then calculate clock
> rates on CSIPHY, CSID and VFE to use the lowest possible.
> 
> If the currnet pixel clock rate of the sensor cannot be read then
> use the highest possible. This case covers also the CSID test
> generator usage.
> 
> If VFE is already powered on by another pipeline, check that the
> current VFE clock rate is high enough for the new pipeline.
> If not return busy error code as VFE clock rate cannot be changed
> while VFE is running.
> 
> Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
> ---
>  .../media/platform/qcom/camss-8x16/camss-csid.c    | 324 ++++++++++++++-------
>  .../media/platform/qcom/camss-8x16/camss-csid.h    |   2 +-
>  .../media/platform/qcom/camss-8x16/camss-csiphy.c  | 112 +++++--
>  .../media/platform/qcom/camss-8x16/camss-csiphy.h  |   2 +-
>  .../media/platform/qcom/camss-8x16/camss-ispif.c   |  23 +-
>  .../media/platform/qcom/camss-8x16/camss-ispif.h   |   4 +-
>  drivers/media/platform/qcom/camss-8x16/camss-vfe.c | 289 +++++++++++++++---
>  drivers/media/platform/qcom/camss-8x16/camss-vfe.h |   2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c     |  51 +++-
>  drivers/media/platform/qcom/camss-8x16/camss.h     |  17 +-
>  10 files changed, 634 insertions(+), 192 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
> index 2bf3415..5c0e359 100644
> --- a/drivers/media/platform/qcom/camss-8x16/camss-csid.c
> +++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
> @@ -68,122 +68,224 @@ static const struct {
>  	u8 data_type;
>  	u8 decode_format;
>  	u8 uncompr_bpp;
> +	u8 spp; /* bus samples per pixel */
>  } csid_input_fmts[] = {
>  	{
>  		MEDIA_BUS_FMT_UYVY8_2X8,
>  		MEDIA_BUS_FMT_UYVY8_2X8,
>  		DATA_TYPE_YUV422_8BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_8_BIT,
> -		16
> +		8,
> +		2

If your original patch had added the comma on the previous line, this would
be simply adding a line per array entry.

>  	},
>  	{
>  		MEDIA_BUS_FMT_VYUY8_2X8,
>  		MEDIA_BUS_FMT_VYUY8_2X8,
>  		DATA_TYPE_YUV422_8BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_8_BIT,
> -		16
> +		8,
> +		2
>  	},
>  	{
>  		MEDIA_BUS_FMT_YUYV8_2X8,
>  		MEDIA_BUS_FMT_YUYV8_2X8,
>  		DATA_TYPE_YUV422_8BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_8_BIT,
> -		16
> +		8,
> +		2
>  	},
>  	{
>  		MEDIA_BUS_FMT_YVYU8_2X8,
>  		MEDIA_BUS_FMT_YVYU8_2X8,
>  		DATA_TYPE_YUV422_8BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_8_BIT,
> -		16
> +		8,
> +		2
>  	},
>  	{
>  		MEDIA_BUS_FMT_SBGGR8_1X8,
>  		MEDIA_BUS_FMT_SBGGR8_1X8,
>  		DATA_TYPE_RAW_8BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_8_BIT,
> -		8
> +		8,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SGBRG8_1X8,
>  		MEDIA_BUS_FMT_SGBRG8_1X8,
>  		DATA_TYPE_RAW_8BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_8_BIT,
> -		8
> +		8,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SGRBG8_1X8,
>  		MEDIA_BUS_FMT_SGRBG8_1X8,
>  		DATA_TYPE_RAW_8BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_8_BIT,
> -		8
> +		8,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SRGGB8_1X8,
>  		MEDIA_BUS_FMT_SRGGB8_1X8,
>  		DATA_TYPE_RAW_8BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_8_BIT,
> -		8
> +		8,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SBGGR10_1X10,
>  		MEDIA_BUS_FMT_SBGGR10_1X10,
>  		DATA_TYPE_RAW_10BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_10_BIT,
> -		10
> +		10,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SGBRG10_1X10,
>  		MEDIA_BUS_FMT_SGBRG10_1X10,
>  		DATA_TYPE_RAW_10BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_10_BIT,
> -		10
> +		10,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SGRBG10_1X10,
>  		MEDIA_BUS_FMT_SGRBG10_1X10,
>  		DATA_TYPE_RAW_10BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_10_BIT,
> -		10
> +		10,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SRGGB10_1X10,
>  		MEDIA_BUS_FMT_SRGGB10_1X10,
>  		DATA_TYPE_RAW_10BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_10_BIT,
> -		10
> +		10,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SBGGR12_1X12,
>  		MEDIA_BUS_FMT_SBGGR12_1X12,
>  		DATA_TYPE_RAW_12BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_12_BIT,
> -		12
> +		12,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SGBRG12_1X12,
>  		MEDIA_BUS_FMT_SGBRG12_1X12,
>  		DATA_TYPE_RAW_12BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_12_BIT,
> -		12
> +		12,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SGRBG12_1X12,
>  		MEDIA_BUS_FMT_SGRBG12_1X12,
>  		DATA_TYPE_RAW_12BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_12_BIT,
> -		12
> +		12,
> +		1
>  	},
>  	{
>  		MEDIA_BUS_FMT_SRGGB12_1X12,
>  		MEDIA_BUS_FMT_SRGGB12_1X12,
>  		DATA_TYPE_RAW_12BIT,
>  		DECODE_FORMAT_UNCOMPRESSED_12_BIT,
> -		12
> +		12,
> +		1
>  	}
>  };
>  
>  /*
> + * csid_get_uncompressed - map media bus format to uncompressed media bus format
> + * @code: media bus format code
> + *
> + * Return uncompressed media bus format code
> + */
> +static u32 csid_get_uncompressed(u32 code)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(csid_input_fmts); i++)
> +		if (code == csid_input_fmts[i].code)
> +			break;
> +
> +	return csid_input_fmts[i].uncompressed;
> +}

I think my suggestion of returning an array entry (a struct) was a good
one. :-)

> +
> +/*
> + * csid_get_data_type - map media bus format to data type
> + * @code: media bus format code
> + *
> + * Return data type code
> + */
> +static u8 csid_get_data_type(u32 code)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(csid_input_fmts); i++)
> +		if (code == csid_input_fmts[i].code)
> +			break;
> +
> +	return csid_input_fmts[i].data_type;
> +}
> +
> +/*
> + * csid_get_decode_format - map media bus format to decode format
> + * @code: media bus format code
> + *
> + * Return decode format code
> + */
> +static u8 csid_get_decode_format(u32 code)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(csid_input_fmts); i++)
> +		if (code == csid_input_fmts[i].code)
> +			break;
> +
> +	return csid_input_fmts[i].decode_format;
> +}
> +
> +/*
> + * csid_get_bpp - map media bus format to bits per pixel
> + * @code: media bus format code
> + *
> + * Return number of bits per pixel
> + */
> +static u8 csid_get_bpp(u32 code)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(csid_input_fmts); i++)
> +		if (code == csid_input_fmts[i].uncompressed)
> +			break;
> +
> +	return csid_input_fmts[i].uncompr_bpp;
> +}
> +
> +/*
> + * csid_get_spp - map media bus format to bus samples per pixel
> + * @code: media bus format code
> + *
> + * Return number of bus samples per pixel
> + */
> +static u8 csid_get_spp(u32 code)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(csid_input_fmts); i++)
> +		if (code == csid_input_fmts[i].uncompressed)
> +			break;
> +
> +	return csid_input_fmts[i].spp;
> +}
> +
> +/*
>   * csid_isr - CSID module interrupt handler
>   * @irq: Interrupt line
>   * @dev: CSID device

-- 
Regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

  parent reply	other threads:[~2017-07-20 15:23 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-17 10:33 [PATCH v3 00/23] Qualcomm 8x16 Camera Subsystem driver Todor Tomov
2017-07-17 10:33 ` [PATCH v3 01/23] [media] media: Make parameter of media_entity_remote_pad() const Todor Tomov
2017-07-17 10:33 ` [PATCH v3 02/23] [media] v4l2-mediabus: Add helper functions Todor Tomov
2017-07-17 10:33 ` [PATCH v3 03/23] v4l: Add packed Bayer raw12 pixel formats Todor Tomov
2017-07-17 10:33 ` [PATCH v3 04/23] dt-bindings: media: Binding document for Qualcomm Camera subsystem driver Todor Tomov
2017-07-20 10:13   ` Sakari Ailus
2017-08-04 11:54     ` Todor Tomov
2017-08-05  8:19       ` Sakari Ailus
2017-07-20 10:15   ` Sakari Ailus
2017-07-24 16:43   ` Rob Herring
2017-07-17 10:33 ` [PATCH v3 05/23] MAINTAINERS: Add " Todor Tomov
2017-07-17 10:33 ` [PATCH v3 06/23] doc: media/v4l-drivers: Add Qualcomm Camera Subsystem driver document Todor Tomov
2017-07-17 10:33 ` [PATCH v3 07/23] media: camss: Add CSIPHY files Todor Tomov
2017-07-20 12:15   ` Sakari Ailus
2017-07-17 10:33 ` [PATCH v3 08/23] media: camss: Add CSID files Todor Tomov
2017-07-20 14:13   ` Sakari Ailus
2017-07-17 10:33 ` [PATCH v3 09/23] media: camss: Add ISPIF files Todor Tomov
2017-07-20 14:51   ` Sakari Ailus
2017-07-17 10:33 ` [PATCH v3 10/23] media: camss: Add VFE files Todor Tomov
2017-07-20 14:59   ` Sakari Ailus
2017-07-25 14:02     ` Todor Tomov
2017-08-04 18:02       ` Sakari Ailus
2017-08-07  6:49         ` Todor Tomov
2017-07-17 10:33 ` [PATCH v3 11/23] media: camss: Add files which handle the video device nodes Todor Tomov
2017-07-17 10:33 ` [PATCH v3 12/23] media: camms: Add core files Todor Tomov
2017-07-19 10:44   ` Hans Verkuil
2017-07-17 10:33 ` [PATCH v3 13/23] media: camss: Enable building Todor Tomov
2017-07-19 13:17   ` kbuild test robot
2017-07-17 10:33 ` [PATCH v3 14/23] camss: vfe: Format conversion support using PIX interface Todor Tomov
2017-07-20 15:11   ` Sakari Ailus
2017-07-17 10:33 ` [PATCH v3 15/23] doc: media/v4l-drivers: Qualcomm Camera Subsystem - PIX Interface Todor Tomov
2017-07-20 15:13   ` Sakari Ailus
2017-07-17 10:33 ` [PATCH v3 16/23] camss: vfe: Support for frame padding Todor Tomov
2017-07-20 15:17   ` Sakari Ailus
2018-09-03 15:38     ` Todor Tomov
2018-09-13 15:04       ` Sakari Ailus
2017-07-17 10:33 ` [PATCH v3 17/23] camss: vfe: Add interface for scaling Todor Tomov
2017-07-20 15:20   ` Sakari Ailus
2017-07-25 15:36     ` Todor Tomov
2017-08-04 17:59       ` Sakari Ailus
2017-07-17 10:33 ` [PATCH v3 18/23] camss: vfe: Configure scaler module in VFE Todor Tomov
2017-07-17 10:33 ` [PATCH v3 19/23] camss: vfe: Add interface for cropping Todor Tomov
2017-07-17 10:33 ` [PATCH v3 20/23] camss: vfe: Configure crop module in VFE Todor Tomov
2017-07-17 10:33 ` [PATCH v3 21/23] doc: media/v4l-drivers: Qualcomm Camera Subsystem - Scale and crop Todor Tomov
2017-07-17 10:33 ` [PATCH v3 22/23] camss: Use optimal clock frequency rates Todor Tomov
2017-07-19 15:59   ` kbuild test robot
2017-07-21  7:55     ` Todor Tomov
2017-07-20 15:23   ` Sakari Ailus [this message]
2017-07-17 10:33 ` [PATCH v3 23/23] doc: media/v4l-drivers: Qualcomm Camera Subsystem - Media graph Todor Tomov
2017-07-19 10:54 ` [PATCH v3 00/23] Qualcomm 8x16 Camera Subsystem driver Hans Verkuil
2017-07-21  7:39   ` Todor Tomov
2017-07-31  9:20   ` Hans Verkuil
2017-07-20 15:25 ` Sakari Ailus
2017-07-21  7:50   ` Todor Tomov

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=20170720152313.joqfo7dqg5gbxrfl@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --cc=hans.verkuil@cisco.com \
    --cc=javier@osg.samsung.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=s.nawrocki@samsung.com \
    --cc=todor.tomov@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;
as well as URLs for NNTP newsgroup(s).