* [Patch v3 0/3] media: ov5640: updates
@ 2019-10-04 17:24 Benoit Parrot
2019-10-04 17:24 ` [Patch v3 1/3] media: ov5640: add PIXEL_RATE control Benoit Parrot
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Benoit Parrot @ 2019-10-04 17:24 UTC (permalink / raw)
To: Hans Verkuil, Sakari Ailus, Jacopo Mondi
Cc: linux-media, devicetree, linux-kernel, Benoit Parrot
This patch series is a collection of patches we have been carrying for a
while.
First, it adds support for PIXEL_RATE control which is used by some
CSI2 receiver driver to properly set-up their DPHY.
Then we fix an issue related to having extra sensor enable/disable in
the register array for the 1920x1080 mode.
Finally we restrict the largest resolution which should only be
available at the lowest FPS.
Changes since v2:
- Addressed comment from Sakari and Jacopo.
- Make use of the calc_pixel_rate in set_mode also
- Cleaned up the pixel_rate ctrl struct
- Fix the fps condition checking for the max resolution case
Changes since v1:
- Addressed comment from Sakari.
added a function to calculate the pixel rate and remove the need to
cache its value
Benoit Parrot (3):
media: ov5640: add PIXEL_RATE control
media: ov5640: Fix 1920x1080 mode to remove extra enable/disable
media: ov5640: Make 2592x1944 mode only available at 15 fps
drivers/media/i2c/ov5640.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Patch v3 1/3] media: ov5640: add PIXEL_RATE control
2019-10-04 17:24 [Patch v3 0/3] media: ov5640: updates Benoit Parrot
@ 2019-10-04 17:24 ` Benoit Parrot
2019-10-07 8:03 ` Sakari Ailus
2019-10-04 17:24 ` [Patch v3 2/3] media: ov5640: Fix 1920x1080 mode to remove extra enable/disable Benoit Parrot
2019-10-04 17:24 ` [Patch v3 3/3] media: ov5640: Make 2592x1944 mode only available at 15 fps Benoit Parrot
2 siblings, 1 reply; 7+ messages in thread
From: Benoit Parrot @ 2019-10-04 17:24 UTC (permalink / raw)
To: Hans Verkuil, Sakari Ailus, Jacopo Mondi
Cc: linux-media, devicetree, linux-kernel, Benoit Parrot
Add v4l2 controls to report the pixel rates of each mode. This is
needed by some CSI2 receiver in order to perform proper DPHY
configuration.
Signed-off-by: Benoit Parrot <bparrot@ti.com>
---
drivers/media/i2c/ov5640.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 500d9bbff10b..a3946ca6a13d 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -193,6 +193,7 @@ struct ov5640_mode_info {
struct ov5640_ctrls {
struct v4l2_ctrl_handler handler;
+ struct v4l2_ctrl *pixel_rate;
struct {
struct v4l2_ctrl *auto_exp;
struct v4l2_ctrl *exposure;
@@ -1614,6 +1615,16 @@ ov5640_find_mode(struct ov5640_dev *sensor, enum ov5640_frame_rate fr,
return mode;
}
+static u64 ov5640_calc_pixel_rate(struct ov5640_dev *sensor)
+{
+ u64 rate;
+
+ rate = sensor->current_mode->vtot * sensor->current_mode->htot;
+ rate *= ov5640_framerates[sensor->current_fr];
+
+ return rate;
+}
+
/*
* sensor changes between scaling and subsampling, go through
* exposure calculation
@@ -1818,8 +1829,7 @@ static int ov5640_set_mode(struct ov5640_dev *sensor)
* All the formats we support have 16 bits per pixel, seems to require
* the same rate than YUV, so we can just use 16 bpp all the time.
*/
- rate = mode->vtot * mode->htot * 16;
- rate *= ov5640_framerates[sensor->current_fr];
+ rate = ov5640_calc_pixel_rate(sensor) * 16;
if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
rate = rate / sensor->ep.bus.mipi_csi2.num_data_lanes;
ret = ov5640_set_mipi_pclk(sensor, rate);
@@ -2233,6 +2243,8 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd,
if (mbus_fmt->code != sensor->fmt.code)
sensor->pending_fmt_change = true;
+ __v4l2_ctrl_s_ctrl_int64(sensor->ctrls.pixel_rate,
+ ov5640_calc_pixel_rate(sensor));
out:
mutex_unlock(&sensor->lock);
return ret;
@@ -2657,6 +2669,12 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
/* we can use our own mutex for the ctrl lock */
hdl->lock = &sensor->lock;
+ /* Clock related controls */
+ ctrls->pixel_rate = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_PIXEL_RATE,
+ 0, INT_MAX, 1,
+ ov5640_calc_pixel_rate(sensor));
+ ctrls->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
+
/* Auto/manual white balance */
ctrls->auto_wb = v4l2_ctrl_new_std(hdl, ops,
V4L2_CID_AUTO_WHITE_BALANCE,
@@ -2816,6 +2834,9 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
sensor->frame_interval = fi->interval;
sensor->current_mode = mode;
sensor->pending_mode_change = true;
+
+ __v4l2_ctrl_s_ctrl_int64(sensor->ctrls.pixel_rate,
+ ov5640_calc_pixel_rate(sensor));
}
out:
mutex_unlock(&sensor->lock);
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Patch v3 2/3] media: ov5640: Fix 1920x1080 mode to remove extra enable/disable
2019-10-04 17:24 [Patch v3 0/3] media: ov5640: updates Benoit Parrot
2019-10-04 17:24 ` [Patch v3 1/3] media: ov5640: add PIXEL_RATE control Benoit Parrot
@ 2019-10-04 17:24 ` Benoit Parrot
2019-10-04 17:24 ` [Patch v3 3/3] media: ov5640: Make 2592x1944 mode only available at 15 fps Benoit Parrot
2 siblings, 0 replies; 7+ messages in thread
From: Benoit Parrot @ 2019-10-04 17:24 UTC (permalink / raw)
To: Hans Verkuil, Sakari Ailus, Jacopo Mondi
Cc: linux-media, devicetree, linux-kernel, Benoit Parrot
In the 1920x1080 register array an extra pair of reset ctrl disable
re-enable was causing unwanted init delays.
Signed-off-by: Benoit Parrot <bparrot@ti.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
---
drivers/media/i2c/ov5640.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index a3946ca6a13d..5cebad151546 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -490,7 +490,6 @@ static const struct reg_value ov5640_setting_720P_1280_720[] = {
};
static const struct reg_value ov5640_setting_1080P_1920_1080[] = {
- {0x3008, 0x42, 0, 0},
{0x3c07, 0x08, 0, 0},
{0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0},
{0x3814, 0x11, 0, 0},
@@ -518,7 +517,7 @@ static const struct reg_value ov5640_setting_1080P_1920_1080[] = {
{0x3a0e, 0x03, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x04, 0, 0},
{0x3a15, 0x60, 0, 0}, {0x4407, 0x04, 0, 0},
{0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, {0x3824, 0x04, 0, 0},
- {0x4005, 0x1a, 0, 0}, {0x3008, 0x02, 0, 0},
+ {0x4005, 0x1a, 0, 0},
};
static const struct reg_value ov5640_setting_QSXGA_2592_1944[] = {
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Patch v3 3/3] media: ov5640: Make 2592x1944 mode only available at 15 fps
2019-10-04 17:24 [Patch v3 0/3] media: ov5640: updates Benoit Parrot
2019-10-04 17:24 ` [Patch v3 1/3] media: ov5640: add PIXEL_RATE control Benoit Parrot
2019-10-04 17:24 ` [Patch v3 2/3] media: ov5640: Fix 1920x1080 mode to remove extra enable/disable Benoit Parrot
@ 2019-10-04 17:24 ` Benoit Parrot
2 siblings, 0 replies; 7+ messages in thread
From: Benoit Parrot @ 2019-10-04 17:24 UTC (permalink / raw)
To: Hans Verkuil, Sakari Ailus, Jacopo Mondi
Cc: linux-media, devicetree, linux-kernel, Benoit Parrot
The sensor data sheet clearly state that 2592x1944 only works at 15 fps
make sure we don't try to miss configure the pll out of acceptable
range.
Signed-off-by: Benoit Parrot <bparrot@ti.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
---
drivers/media/i2c/ov5640.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 5cebad151546..8ffb3a55ca27 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -1611,6 +1611,11 @@ ov5640_find_mode(struct ov5640_dev *sensor, enum ov5640_frame_rate fr,
!(mode->hact == 640 && mode->vact == 480))
return NULL;
+ /* 2592x1944 only works at 15fps max */
+ if ((mode->hact == 2592 && mode->vact == 1944) &&
+ fr > OV5640_15_FPS)
+ return NULL;
+
return mode;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Patch v3 1/3] media: ov5640: add PIXEL_RATE control
2019-10-04 17:24 ` [Patch v3 1/3] media: ov5640: add PIXEL_RATE control Benoit Parrot
@ 2019-10-07 8:03 ` Sakari Ailus
2019-10-07 15:17 ` Benoit Parrot
0 siblings, 1 reply; 7+ messages in thread
From: Sakari Ailus @ 2019-10-07 8:03 UTC (permalink / raw)
To: Benoit Parrot
Cc: Hans Verkuil, Jacopo Mondi, linux-media, devicetree, linux-kernel
On Fri, Oct 04, 2019 at 12:24:16PM -0500, Benoit Parrot wrote:
> @@ -2657,6 +2669,12 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
> /* we can use our own mutex for the ctrl lock */
> hdl->lock = &sensor->lock;
>
> + /* Clock related controls */
> + ctrls->pixel_rate = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_PIXEL_RATE,
> + 0, INT_MAX, 1,
> + ov5640_calc_pixel_rate(sensor));
> + ctrls->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
Please check ctrls->pixel_rate first; it may be NULL here.
> +
> /* Auto/manual white balance */
> ctrls->auto_wb = v4l2_ctrl_new_std(hdl, ops,
> V4L2_CID_AUTO_WHITE_BALANCE,
--
Sakari Ailus
sakari.ailus@linux.intel.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch v3 1/3] media: ov5640: add PIXEL_RATE control
2019-10-07 8:03 ` Sakari Ailus
@ 2019-10-07 15:17 ` Benoit Parrot
2019-10-08 6:58 ` Sakari Ailus
0 siblings, 1 reply; 7+ messages in thread
From: Benoit Parrot @ 2019-10-07 15:17 UTC (permalink / raw)
To: Sakari Ailus
Cc: Hans Verkuil, Jacopo Mondi, linux-media, devicetree, linux-kernel
Sakari Ailus <sakari.ailus@linux.intel.com> wrote on Mon [2019-Oct-07 11:03:20 +0300]:
> On Fri, Oct 04, 2019 at 12:24:16PM -0500, Benoit Parrot wrote:
> > @@ -2657,6 +2669,12 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
> > /* we can use our own mutex for the ctrl lock */
> > hdl->lock = &sensor->lock;
> >
> > + /* Clock related controls */
> > + ctrls->pixel_rate = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_PIXEL_RATE,
> > + 0, INT_MAX, 1,
> > + ov5640_calc_pixel_rate(sensor));
> > + ctrls->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
>
> Please check ctrls->pixel_rate first; it may be NULL here.
How about I just move this line below "if (hdl->error)" instead?
Benoit
>
> > +
> > /* Auto/manual white balance */
> > ctrls->auto_wb = v4l2_ctrl_new_std(hdl, ops,
> > V4L2_CID_AUTO_WHITE_BALANCE,
>
> --
> Sakari Ailus
> sakari.ailus@linux.intel.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch v3 1/3] media: ov5640: add PIXEL_RATE control
2019-10-07 15:17 ` Benoit Parrot
@ 2019-10-08 6:58 ` Sakari Ailus
0 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2019-10-08 6:58 UTC (permalink / raw)
To: Benoit Parrot
Cc: Hans Verkuil, Jacopo Mondi, linux-media, devicetree, linux-kernel
On Mon, Oct 07, 2019 at 10:17:03AM -0500, Benoit Parrot wrote:
> Sakari Ailus <sakari.ailus@linux.intel.com> wrote on Mon [2019-Oct-07 11:03:20 +0300]:
> > On Fri, Oct 04, 2019 at 12:24:16PM -0500, Benoit Parrot wrote:
> > > @@ -2657,6 +2669,12 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
> > > /* we can use our own mutex for the ctrl lock */
> > > hdl->lock = &sensor->lock;
> > >
> > > + /* Clock related controls */
> > > + ctrls->pixel_rate = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_PIXEL_RATE,
> > > + 0, INT_MAX, 1,
> > > + ov5640_calc_pixel_rate(sensor));
> > > + ctrls->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> >
> > Please check ctrls->pixel_rate first; it may be NULL here.
>
> How about I just move this line below "if (hdl->error)" instead?
That's fine, too. As long as it won't oops if memory allocation fails...
:-)
--
Sakari Ailus
sakari.ailus@linux.intel.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-10-08 6:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 17:24 [Patch v3 0/3] media: ov5640: updates Benoit Parrot
2019-10-04 17:24 ` [Patch v3 1/3] media: ov5640: add PIXEL_RATE control Benoit Parrot
2019-10-07 8:03 ` Sakari Ailus
2019-10-07 15:17 ` Benoit Parrot
2019-10-08 6:58 ` Sakari Ailus
2019-10-04 17:24 ` [Patch v3 2/3] media: ov5640: Fix 1920x1080 mode to remove extra enable/disable Benoit Parrot
2019-10-04 17:24 ` [Patch v3 3/3] media: ov5640: Make 2592x1944 mode only available at 15 fps Benoit Parrot
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).