All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-media@vger.kernel.org, dacohen@gmail.com, snjw23@gmail.com,
	andriy.shevchenko@linux.intel.com, t.stanislaws@samsung.com,
	tuukkat76@gmail.com, k.debski@samsung.com, riverful@gmail.com,
	hverkuil@xs4all.nl, teturtia@gmail.com,
	pradeep.sawlani@gmail.com
Subject: Re: [PATCH v5 34/35] smiapp: Generic SMIA++/SMIA PLL calculator
Date: Wed, 07 Mar 2012 13:26:20 +0100	[thread overview]
Message-ID: <1960253.l1xo097dr7@avalon> (raw)
In-Reply-To: <1331051596-8261-34-git-send-email-sakari.ailus@iki.fi>

Hi Sakari,

Thanks for the patch.

On Tuesday 06 March 2012 18:33:15 Sakari Ailus wrote:
> From: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
> 
> Calculate PLL configuration based on input data: sensor configuration, board
> properties and sensor-specific limits.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>

[snip]

> diff --git a/drivers/media/video/smiapp-pll.c
> b/drivers/media/video/smiapp-pll.c new file mode 100644
> index 0000000..3a999c0
> --- /dev/null
> +++ b/drivers/media/video/smiapp-pll.c

[snip]

> +int smiapp_pll_calculate(struct device *dev, struct smiapp_pll_limits
> *limits,
> +			 struct smiapp_pll *pll)
> +{

[snip]

> +	/*
> +	 * Some sensors perform analogue binning and some do this
> +	 * digitally. The ones doing this digitally can be roughly be
> +	 * found out using this formula. The ones doing this digitally
> +	 * should run at higher clock rate, so smaller divisor is used
> +	 * on video timing side.
> +	 */
> +	if (limits->min_line_length_pck_bin > limits->min_line_length_pck
> +	    / pll->binning_horizontal)
> +		vt_op_binning_div = pll->binning_horizontal;
> +	else
> +		vt_op_binning_div = 1;
> +	dev_dbg(dev, "vt_op_binning_div: %d\n", vt_op_binning_div);
> +
> +	/*
> +	 * Profile 2 supports vt_pix_clk_div E [4, 10]
> +	 *
> +	 * Horizontal binning can be used as a base for difference in
> +	 * divisors. One must make sure that horizontal blanking is
> +	 * enough to accommodate the CSI-2 sync codes.
> +	 *
> +	 * Take scaling factor into account as well.
> +	 *
> +	 * Find absolute limits for the factor of vt divider.
> +	 */
> +	dev_dbg(dev, "scale_m: %d\n", pll->scale_m);
> +	min_vt_div = DIV_ROUND_UP(pll->op_pix_clk_div * pll->op_sys_clk_div
> +				  * pll->scale_n,

I still need

        if (pll->flags & SMIAPP_PLL_FLAG_DUAL_READOUT)
               num_readout_paths = 2;
        else
               num_readout_paths = 1;
        min_vt_div = DIV_ROUND_UP(pll->op_pix_clk_div * pll->op_sys_clk_div
                                 * pll->scale_n * num_readout_paths,

for the AR0330 driver, but I can add that later.

> +				  lane_op_clock_ratio * vt_op_binning_div
> +				  * pll->scale_m);

[snip]

> +	/*
> +	 * Find pix_div such that a legal pix_div * sys_div results
> +	 * into a value which is not smaller than div, the desired
> +	 * divisor.
> +	 */
> +	for (vt_div = min_vt_div; vt_div <= max_vt_div;
> +	     vt_div += 2 - (vt_div & 1)) {
> +		for (sys_div = min_sys_div;
> +		     sys_div <= max_sys_div;
> +		     sys_div += 2 - (sys_div & 1)) {
> +			int pix_div = DIV_ROUND_UP(vt_div, sys_div);
> +
> +			if (pix_div <
> +			    limits->min_vt_pix_clk_div
> +			    || pix_div
> +			    > limits->max_vt_pix_clk_div) {

			if (pix_div < limits->min_vt_pix_clk_div ||
			    pix_div > limits->max_vt_pix_clk_div) {

> +				dev_dbg(dev,
> +					"pix_div %d too small or too big (%d--%d)\n",
> +					pix_div,
> +					limits->min_vt_pix_clk_div,
> +					limits->max_vt_pix_clk_div);
> +				continue;
> +			}
> +
> +			/* Check if this one is better. */
> +			if (pix_div * sys_div
> +			    <= ALIGN(min_vt_div, best_pix_div))
> +				best_pix_div = pix_div;
> +		}
> +		if (best_pix_div < INT_MAX >> 1)
> +			break;
> +	}

[snip]

> diff --git a/drivers/media/video/smiapp/smiapp-core.c
> b/drivers/media/video/smiapp/smiapp-core.c new file mode 100644
> index 0000000..879fb1e
> --- /dev/null
> +++ b/drivers/media/video/smiapp/smiapp-core.c

[snip]

> +static void smiapp_get_crop_compose(struct v4l2_subdev *subdev,
> +				    struct v4l2_subdev_fh *fh,
> +				    struct v4l2_rect **crops,
> +				    struct v4l2_rect **comps, int which)
> +{
> +	struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
> +	int i;

Can you guess ? :-)

> +
> +	if (which == V4L2_SUBDEV_FORMAT_ACTIVE) {
> +		if (crops)
> +			for (i = 0; i < subdev->entity.num_pads; i++)
> +				crops[i] = &ssd->crop[i];
> +		if (comps)
> +			*comps = &ssd->compose;
> +	} else {
> +		if (crops) {
> +			for (i = 0; i < subdev->entity.num_pads; i++) {
> +				crops[i] = v4l2_subdev_get_try_crop(fh, i);
> +				BUG_ON(!crops[i]);
> +			}
> +		}
> +		if (comps) {
> +			*comps = v4l2_subdev_get_try_compose(fh,
> +							     SMIAPP_PAD_SINK);
> +			BUG_ON(!*comps);
> +		}
> +	}
> +}

[snip]

> +static int smiapp_set_format(struct v4l2_subdev *subdev,
> +			     struct v4l2_subdev_fh *fh,
> +			     struct v4l2_subdev_format *fmt)
> +{
> +	struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
> +	struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
> +	struct v4l2_rect *crops[SMIAPP_PADS];
> +	const struct smiapp_csi_data_format *csi_format = sensor->csi_format;
> +	int i;

:-D

> +
> +	mutex_lock(&sensor->mutex);
> +
> +	smiapp_get_crop_compose(subdev, fh, crops, NULL, fmt->which);
> +
> +	if (subdev == &sensor->src->sd && fmt->pad == SMIAPP_PAD_SRC) {
> +		for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) {
> +			if (sensor->mbus_frame_fmts & (1 << i) &&
> +			    smiapp_csi_data_formats[i].code
> +			    == fmt->format.code) {
> +				csi_format = &smiapp_csi_data_formats[i];
> +				if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
> +					sensor->csi_format = csi_format;
> +				break;
> +			}
> +		}
> +	}
> +
> +	if (fmt->pad == ssd->source_pad) {
> +		int rval;
> +
> +		rval = __smiapp_get_format(subdev, fh, fmt);
> +		fmt->format.code = csi_format->code;
> +
> +		mutex_unlock(&sensor->mutex);
> +		return rval;
> +	}
> +
> +	fmt->format.code = csi_format->code;

This will result in the format code at the output of the pixel array being
equal to the format code at the output of the binner/scaler. I don't think
you want that.

You probably need to take a small step back and rethink the code flow in this
function a bit. I'm pretty sure you can keep it simple.

> +	fmt->format.width &= ~1;
> +	fmt->format.height &= ~1;
> +
> +	fmt->format.width =
> +		clamp(fmt->format.width,
> +		      sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE],
> +		      sensor->limits[SMIAPP_LIMIT_MAX_X_OUTPUT_SIZE]);
> +	fmt->format.height =
> +		clamp(fmt->format.height,
> +		      sensor->limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE],
> +		      sensor->limits[SMIAPP_LIMIT_MAX_Y_OUTPUT_SIZE]);
> +
> +	crops[ssd->sink_pad]->left = 0;
> +	crops[ssd->sink_pad]->top = 0;
> +	crops[ssd->sink_pad]->width = fmt->format.width;
> +	crops[ssd->sink_pad]->height = fmt->format.height;
> +	if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
> +		ssd->sink_fmt = *crops[ssd->sink_pad];
> +	smiapp_propagate(subdev, fh, fmt->which,
> +			 V4L2_SUBDEV_SEL_TGT_CROP_ACTIVE);
> +
> +	mutex_unlock(&sensor->mutex);
> +
> +	return 0;
> +}

[snip]

-- 
Regards,

Laurent Pinchart



  reply	other threads:[~2012-03-07 12:26 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-06 16:32 [PATCH v5 0/35] V4L2 subdev and sensor control changes, SMIA++ driver and N9 camera board code Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 01/35] v4l: Introduce integer menu controls Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 02/35] v4l: Document " Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 03/35] vivi: Add an integer menu test control Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 04/35] v4l: VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 05/35] v4l: vdev_to_v4l2_subdev() should have return type "struct v4l2_subdev *" Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 06/35] v4l: Check pad number in get try pointer functions Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 07/35] v4l: Support s_crop and g_crop through s/g_selection Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 08/35] v4l: Add subdev selections documentation: svg and dia files Sakari Ailus
2012-03-06 16:42   ` Laurent Pinchart
2012-03-06 16:32 ` [PATCH v5 09/35] v4l: Add subdev selections documentation Sakari Ailus
2012-03-06 16:44   ` Laurent Pinchart
2012-03-07  8:53   ` Michael Jones
2012-03-07 18:11     ` Sakari Ailus
2012-03-15  9:55   ` Sylwester Nawrocki
2012-03-15 13:00     ` Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 10/35] v4l: Mark VIDIOC_SUBDEV_G_CROP and VIDIOC_SUBDEV_S_CROP obsolete Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 11/35] v4l: Image source control class Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 12/35] v4l: Image processing " Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 13/35] v4l: Document raw bayer 4CC codes Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 14/35] v4l: Add DPCM compressed raw bayer pixel formats Sakari Ailus
2012-03-21  9:37   ` Prabhakar Lad
2012-03-21  9:53     ` Sakari Ailus
2012-03-21 11:44     ` [PATCH v5.5 14/40] " Sakari Ailus
2012-03-21 12:08       ` Prabhakar Lad
2012-03-06 16:32 ` [PATCH v5 15/35] media: Add link_validate() op to check links to the sink pad Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 16/35] v4l: Improve sub-device documentation for pad ops Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 17/35] v4l: Implement v4l2_subdev_link_validate() Sakari Ailus
2012-03-06 16:32 ` [PATCH v5 18/35] v4l: Allow changing control handler lock Sakari Ailus
2012-05-14 15:27   ` Sylwester Nawrocki
2012-05-14 15:45     ` Sakari Ailus
2012-05-14 16:02       ` Sylwester Nawrocki
2012-05-14 15:48     ` Sylwester Nawrocki
2012-03-06 16:33 ` [PATCH v5 19/35] omap3isp: Support additional in-memory compressed bayer formats Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 20/35] omap3isp: Move definitions required by board code under include/media Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 21/35] omap3: add definition for CONTROL_CAMERA_PHY_CTRL Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 22/35] omap3isp: Move setting constaints above media_entity_pipeline_start Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 23/35] omap3isp: Assume media_entity_pipeline_start may fail Sakari Ailus
2012-03-06 16:45   ` Laurent Pinchart
2012-03-06 16:33 ` [PATCH v5 24/35] omap3isp: Add lane configuration to platform data Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 25/35] omap3isp: Collect entities that are part of the pipeline Sakari Ailus
2012-03-07 10:35   ` Laurent Pinchart
2012-03-07 17:20     ` Sakari Ailus
2012-03-07 17:22       ` [PATCH v5.1 " Sakari Ailus
2012-03-07 23:50         ` Laurent Pinchart
2012-03-09 18:44           ` [PATCH " Sakari Ailus
2012-03-09 20:31           ` [PATCH v5.3 " Sakari Ailus
2012-03-09 20:34             ` Laurent Pinchart
2012-03-08 17:05     ` Sakari Ailus
2012-03-07 10:50   ` [PATCH v5 " Laurent Pinchart
2012-03-07 15:24     ` Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 26/35] omap3isp: Add information on external subdev to struct isp_pipeline Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 27/35] omap3isp: Introduce isp_video_check_external_subdevs() Sakari Ailus
2012-03-07 10:43   ` Laurent Pinchart
2012-03-07 17:49     ` Sakari Ailus
2012-03-07 18:52       ` Laurent Pinchart
2012-03-07 23:57         ` Sakari Ailus
2012-03-08 17:04         ` [PATCH v5.3 " Sakari Ailus
2012-03-08 18:05           ` Laurent Pinchart
2012-03-07 18:14     ` [PATCH v5.1 " Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 28/35] omap3isp: Use external rate instead of vpcfg Sakari Ailus
2012-03-07 10:53   ` Laurent Pinchart
2012-03-07 17:54     ` Sakari Ailus
2012-03-07 18:34     ` Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 29/35] omap3isp: Default link validation for ccp2, csi2, preview and resizer Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 30/35] omap3isp: Move CCDC link validation to ccdc_link_validate() Sakari Ailus
2012-03-07 11:00   ` Laurent Pinchart
2012-03-07 18:02     ` Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 31/35] omap3isp: Configure CSI-2 phy based on platform data Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 32/35] omap3isp: Add resizer data rate configuration to resizer_link_validate Sakari Ailus
2012-03-07 11:01   ` Laurent Pinchart
2012-03-06 16:33 ` [PATCH v5 33/35] omap3isp: Find source pad from external entity Sakari Ailus
2012-03-07 11:04   ` Laurent Pinchart
2012-03-07 18:08     ` Sakari Ailus
2012-03-06 16:33 ` [PATCH v5 34/35] smiapp: Generic SMIA++/SMIA PLL calculator Sakari Ailus
2012-03-07 12:26   ` Laurent Pinchart [this message]
2012-03-08 13:29     ` Sakari Ailus
2012-03-08 13:57     ` [PATCH v5.1 " Sakari Ailus
2012-03-08 14:38       ` Laurent Pinchart
2012-03-08 14:48         ` Sakari Ailus
2012-03-08 14:49         ` [PATCH v5.2 " Sakari Ailus
2012-03-08 14:51           ` Laurent Pinchart
2012-03-08 13:57     ` [PATCH v5.1 35/35] smiapp: Add driver Sakari Ailus
2012-03-08 14:46       ` Laurent Pinchart
2012-03-08 16:49         ` [PATCH v5.3 " Sakari Ailus
2012-03-11 13:37           ` Laurent Pinchart
2012-03-11 14:03             ` Sakari Ailus
2012-03-11 14:45               ` [PATCH v5.4 " Sakari Ailus
2012-03-11 16:32                 ` Laurent Pinchart
2012-03-08 15:06       ` [PATCH v5.1 " jean-philippe francois
2012-03-11  9:04         ` Sakari Ailus
2012-03-12  9:44           ` jean-philippe francois
2012-03-06 16:33 ` [PATCH v5 35/35] rm680: Add camera init Sakari Ailus

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=1960253.l1xo097dr7@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dacohen@gmail.com \
    --cc=hverkuil@xs4all.nl \
    --cc=k.debski@samsung.com \
    --cc=linux-media@vger.kernel.org \
    --cc=pradeep.sawlani@gmail.com \
    --cc=riverful@gmail.com \
    --cc=sakari.ailus@iki.fi \
    --cc=snjw23@gmail.com \
    --cc=t.stanislaws@samsung.com \
    --cc=teturtia@gmail.com \
    --cc=tuukkat76@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.