* [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support
@ 2021-06-23 18:12 Sakari Ailus
2021-06-23 18:13 ` [PATCH 1/3] Documentation: v4l: Rework LP-11 documentation, add callbacks Sakari Ailus
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Sakari Ailus @ 2021-06-23 18:12 UTC (permalink / raw)
To: linux-media
Cc: Michael Tretter, Marek Vasut, Steve Longerbeam, laurent.pinchart
Hi all,
Some receiver devices requires explicit support for transitioning
transmitters to LP-11 or LP-111 state before starting streaming. As
there's currently a single operation (s_stream()) callback to do that,
there's no way for the receiver driver to differentiate between the two
things.
This set adds two more callbacks, pre_streamon and post_streamon, to do
exactly that. The usage on CSI-2 is to set the transmitter state to LP-11
or LP-111 (depending on the PHY) and thus allow reliable receiver
initialisation.
The set also adds support for this in the CCS driver.
Sakari Ailus (3):
Documentation: v4l: Rework LP-11 documentation, add callbacks
v4l: subdev: Add pre_streamon and post_streamoff callbacks
ccs: Implement support for manual LP control
Documentation/driver-api/media/tx-rx.rst | 40 ++++++++++++++-------
drivers/media/i2c/ccs/ccs-core.c | 45 ++++++++++++++++++++++++
include/media/v4l2-subdev.h | 25 +++++++++++++
3 files changed, 98 insertions(+), 12 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] Documentation: v4l: Rework LP-11 documentation, add callbacks
2021-06-23 18:12 [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support Sakari Ailus
@ 2021-06-23 18:13 ` Sakari Ailus
2021-06-23 18:13 ` [PATCH 2/3] v4l: subdev: Add pre_streamon and post_streamoff callbacks Sakari Ailus
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2021-06-23 18:13 UTC (permalink / raw)
To: linux-media
Cc: Michael Tretter, Marek Vasut, Steve Longerbeam, laurent.pinchart
Rework LP-11 and LP-111 mode documentation to make it more understandable
and useful. This involves adding pre_streamon and post_streamon callbacks
that make it possible to explicitly transition the transmitter to either
mode.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
Documentation/driver-api/media/tx-rx.rst | 40 +++++++++++++++++-------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/Documentation/driver-api/media/tx-rx.rst b/Documentation/driver-api/media/tx-rx.rst
index 4ba274713a61..706e839e8cec 100644
--- a/Documentation/driver-api/media/tx-rx.rst
+++ b/Documentation/driver-api/media/tx-rx.rst
@@ -93,18 +93,34 @@ where
LP-11 and LP-111 modes
^^^^^^^^^^^^^^^^^^^^^^
-The transmitter drivers must, if possible, configure the CSI-2 transmitter to
-*LP-11 or LP-111 mode* whenever the transmitter is powered on but not active,
-and maintain *LP-11 or LP-111 mode* until stream on. Only at stream on time
-should the transmitter activate the clock on the clock lane and transition to
-*HS mode*.
-
-Some transmitters do this automatically but some have to be explicitly
-programmed to do so, and some are unable to do so altogether due to
-hardware constraints.
-
-The receiver thus need to be configured to expect LP-11 or LP-111 mode from the
-transmitter before the transmitter driver's ``.s_stream()`` op is called.
+As part of transitioning to high speed mode, a CSI-2 transmitter typically
+briefly sets the bus to LP-11 or LP-111 state, depending on the PHY. This period
+may be as short as 100 µs, during which the receiver observes this state and
+proceeds its own part of high speed mode transition.
+
+Most receivers are capable of autonomously handling this once the software has
+configured them to do so, but there are receivers which require software
+involvement in observing LP-11 or LP-111 state. 100 µs is a brief period to hit
+in software, especially when there is no interrupt telling something is
+happening.
+
+One way to address this is to configure the transmitter side explicitly to LP-11
+or LP-111 mode, which requires support from the transmitter hardware. This is
+not universally available. Many devices return to this state once streaming is
+stopped while the state after power-on is LP-00 or LP-000.
+
+The ``.pre_streamon()`` callback may be used to prepare a transmitter for
+transitioning to streaming state, but not yet start streaming. Similarly, the
+``.post_streamoff()`` callback is used to undo what was done by the
+``.pre_streamon()`` callback. The caller of ``.pre_streamon()`` is thus required
+to call ``.post_streamoff()`` for each successful call of ``.pre_streamon()``.
+
+In the context of CSI-2, the ``.pre_streamon()`` callback is used to transition
+the transmitter to the LP-11 or LP-111 mode. This also requires powering on the
+device, so this should be only done when it is needed.
+
+Receiver drivers that do not need explicit LP-11 or LP-111 mode setup are waived
+from calling the two callbacks.
Stopping the transmitter
^^^^^^^^^^^^^^^^^^^^^^^^
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] v4l: subdev: Add pre_streamon and post_streamoff callbacks
2021-06-23 18:12 [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support Sakari Ailus
2021-06-23 18:13 ` [PATCH 1/3] Documentation: v4l: Rework LP-11 documentation, add callbacks Sakari Ailus
@ 2021-06-23 18:13 ` Sakari Ailus
2021-06-23 18:13 ` [PATCH 3/3] ccs: Implement support for manual LP control Sakari Ailus
2021-06-23 18:18 ` [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support Sakari Ailus
3 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2021-06-23 18:13 UTC (permalink / raw)
To: linux-media
Cc: Michael Tretter, Marek Vasut, Steve Longerbeam, laurent.pinchart
Add pre_streamon and post_streamoff callbacks that can be used to set a
CSI-2 transmitter to LP-11 or LP-111 mode. This can be used by receiver
drivers to reliably initialise the receiver when its initialisation
requires software involvement.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/media/v4l2-subdev.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 5364e3a6ac9b..95ec18c2f49c 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -354,6 +354,16 @@ struct v4l2_mbus_frame_desc {
unsigned short num_entries;
};
+/**
+ * enum v4l2_subdev_pre_streamon_flags - Flags for pre_streamon subdev core op
+ *
+ * @V4L2_SUBDEV_PRE_STREAMON_FL_MANUAL_LP: Set the transmitter to either LP-11
+ * or LP-111 mode before call to s_stream().
+ */
+enum v4l2_subdev_pre_streamon_flags {
+ V4L2_SUBDEV_PRE_STREAMON_FL_MANUAL_LP = BIT(0),
+};
+
/**
* struct v4l2_subdev_video_ops - Callbacks used when v4l device was opened
* in video mode.
@@ -409,6 +419,19 @@ struct v4l2_mbus_frame_desc {
* @s_rx_buffer: set a host allocated memory buffer for the subdev. The subdev
* can adjust @size to a lower value and must not write more data to the
* buffer starting at @data than the original value of @size.
+ *
+ * @pre_streamon: May be called before streaming is actually started, to help
+ * initialising the bus. Current usage is to set a CSI-2 transmitter to
+ * LP-11 or LP-111 mode before streaming. See &enum
+ * v4l2_subdev_pre_streamon_flags.
+ *
+ * pre_streamon shall return error if it cannot perform the operation as
+ * indicated by the flags argument. In particular, -EACCES indicates lack
+ * of support for the operation. The caller shall call post_streamoff for
+ * each successful call of pre_streamon.
+ *
+ * @post_streamoff: Called after streaming is stopped, but if and only if
+ * pre_streamon was called earlier.
*/
struct v4l2_subdev_video_ops {
int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
@@ -435,6 +458,8 @@ struct v4l2_subdev_video_ops {
struct v4l2_dv_timings *timings);
int (*s_rx_buffer)(struct v4l2_subdev *sd, void *buf,
unsigned int *size);
+ int (*pre_streamon)(struct v4l2_subdev *sd, u32 flags);
+ int (*post_streamoff)(struct v4l2_subdev *sd);
};
/**
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] ccs: Implement support for manual LP control
2021-06-23 18:12 [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support Sakari Ailus
2021-06-23 18:13 ` [PATCH 1/3] Documentation: v4l: Rework LP-11 documentation, add callbacks Sakari Ailus
2021-06-23 18:13 ` [PATCH 2/3] v4l: subdev: Add pre_streamon and post_streamoff callbacks Sakari Ailus
@ 2021-06-23 18:13 ` Sakari Ailus
2021-07-08 13:44 ` [PATCH v2 " Sakari Ailus
2021-06-23 18:18 ` [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support Sakari Ailus
3 siblings, 1 reply; 6+ messages in thread
From: Sakari Ailus @ 2021-06-23 18:13 UTC (permalink / raw)
To: linux-media
Cc: Michael Tretter, Marek Vasut, Steve Longerbeam, laurent.pinchart
Use the pre_streamon callback to transition the transmitter to either
LP-11 or LP-111 mode if supported by the sensor.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ccs/ccs-core.c | 45 ++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index a9403a227c6b..918be5a020f2 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -1943,6 +1943,49 @@ static int ccs_set_stream(struct v4l2_subdev *subdev, int enable)
return rval;
}
+static int ccs_pre_streamon(struct v4l2_subdev *subdev, u32 flags)
+{
+ struct ccs_sensor *sensor = to_ccs_sensor(subdev);
+ struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+ int rval;
+
+ switch (sensor->hwcfg.csi_signalling_mode) {
+ case CCS_CSI_SIGNALING_MODE_CSI_2_DPHY:
+ if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) &
+ CCS_PHY_CTRL_CAPABILITY_2_MANUAL_LP_DPHY))
+ return -EACCES;
+ break;
+ case CCS_CSI_SIGNALING_MODE_CSI_2_CPHY:
+ if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) &
+ CCS_PHY_CTRL_CAPABILITY_2_MANUAL_LP_CPHY))
+ return -EACCES;
+ break;
+ default:
+ return -EACCES;
+ }
+
+ rval = ccs_pm_get_init(sensor);
+ if (rval)
+ return rval;
+
+ if (flags & V4L2_SUBDEV_PRE_STREAMON_FL_MANUAL_LP) {
+ rval = ccs_write(sensor, MANUAL_LP_CTRL,
+ CCS_MANUAL_LP_CTRL_ENABLE);
+ if (rval)
+ pm_runtime_put(&client->dev);
+ }
+
+ return rval;
+}
+
+static int ccs_post_streamoff(struct v4l2_subdev *subdev)
+{
+ struct ccs_sensor *sensor = to_ccs_sensor(subdev);
+ struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+
+ return pm_runtime_put(&client->dev);
+}
+
static int ccs_enum_mbus_code(struct v4l2_subdev *subdev,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
@@ -3058,6 +3101,8 @@ static int ccs_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
static const struct v4l2_subdev_video_ops ccs_video_ops = {
.s_stream = ccs_set_stream,
+ .pre_streamon = ccs_pre_streamon,
+ .post_streamoff = ccs_post_streamoff,
};
static const struct v4l2_subdev_pad_ops ccs_pad_ops = {
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support
2021-06-23 18:12 [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support Sakari Ailus
` (2 preceding siblings ...)
2021-06-23 18:13 ` [PATCH 3/3] ccs: Implement support for manual LP control Sakari Ailus
@ 2021-06-23 18:18 ` Sakari Ailus
3 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2021-06-23 18:18 UTC (permalink / raw)
To: Sakari Ailus
Cc: linux-media, Michael Tretter, Marek Vasut, Steve Longerbeam,
laurent.pinchart
On Wed, Jun 23, 2021 at 09:12:59PM +0300, Sakari Ailus wrote:
> Hi all,
>
> Some receiver devices requires explicit support for transitioning
> transmitters to LP-11 or LP-111 state before starting streaming. As
> there's currently a single operation (s_stream()) callback to do that,
> there's no way for the receiver driver to differentiate between the two
> things.
>
> This set adds two more callbacks, pre_streamon and post_streamon, to do
> exactly that. The usage on CSI-2 is to set the transmitter state to LP-11
> or LP-111 (depending on the PHY) and thus allow reliable receiver
> initialisation.
>
> The set also adds support for this in the CCS driver.
I forgot to mention the set goes on top of my earlier patches I sent
recently. This is all here:
https://git.linuxtv.org/sailus/media_tree.git/ camera-stuff
--
Sakari Ailus
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] ccs: Implement support for manual LP control
2021-06-23 18:13 ` [PATCH 3/3] ccs: Implement support for manual LP control Sakari Ailus
@ 2021-07-08 13:44 ` Sakari Ailus
0 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2021-07-08 13:44 UTC (permalink / raw)
To: linux-media
Cc: Michael Tretter, Marek Vasut, Steve Longerbeam, laurent.pinchart
Use the pre_streamon callback to transition the transmitter to either
LP-11 or LP-111 mode if supported by the sensor.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
since v1:
- Only check sensor capabilities if manual LP control is requested.
drivers/media/i2c/ccs/ccs-core.c | 47 ++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 121cbe406fe4..5363f3bcafe3 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -1943,6 +1943,51 @@ static int ccs_set_stream(struct v4l2_subdev *subdev, int enable)
return rval;
}
+static int ccs_pre_streamon(struct v4l2_subdev *subdev, u32 flags)
+{
+ struct ccs_sensor *sensor = to_ccs_sensor(subdev);
+ struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+ int rval;
+
+ if (flags & V4L2_SUBDEV_PRE_STREAMON_FL_MANUAL_LP) {
+ switch (sensor->hwcfg.csi_signalling_mode) {
+ case CCS_CSI_SIGNALING_MODE_CSI_2_DPHY:
+ if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) &
+ CCS_PHY_CTRL_CAPABILITY_2_MANUAL_LP_DPHY))
+ return -EACCES;
+ break;
+ case CCS_CSI_SIGNALING_MODE_CSI_2_CPHY:
+ if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) &
+ CCS_PHY_CTRL_CAPABILITY_2_MANUAL_LP_CPHY))
+ return -EACCES;
+ break;
+ default:
+ return -EACCES;
+ }
+ }
+
+ rval = ccs_pm_get_init(sensor);
+ if (rval)
+ return rval;
+
+ if (flags & V4L2_SUBDEV_PRE_STREAMON_FL_MANUAL_LP) {
+ rval = ccs_write(sensor, MANUAL_LP_CTRL,
+ CCS_MANUAL_LP_CTRL_ENABLE);
+ if (rval)
+ pm_runtime_put(&client->dev);
+ }
+
+ return rval;
+}
+
+static int ccs_post_streamoff(struct v4l2_subdev *subdev)
+{
+ struct ccs_sensor *sensor = to_ccs_sensor(subdev);
+ struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+
+ return pm_runtime_put(&client->dev);
+}
+
static int ccs_enum_mbus_code(struct v4l2_subdev *subdev,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
@@ -3055,6 +3100,8 @@ static int ccs_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
static const struct v4l2_subdev_video_ops ccs_video_ops = {
.s_stream = ccs_set_stream,
+ .pre_streamon = ccs_pre_streamon,
+ .post_streamoff = ccs_post_streamoff,
};
static const struct v4l2_subdev_pad_ops ccs_pad_ops = {
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-07-08 13:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 18:12 [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support Sakari Ailus
2021-06-23 18:13 ` [PATCH 1/3] Documentation: v4l: Rework LP-11 documentation, add callbacks Sakari Ailus
2021-06-23 18:13 ` [PATCH 2/3] v4l: subdev: Add pre_streamon and post_streamoff callbacks Sakari Ailus
2021-06-23 18:13 ` [PATCH 3/3] ccs: Implement support for manual LP control Sakari Ailus
2021-07-08 13:44 ` [PATCH v2 " Sakari Ailus
2021-06-23 18:18 ` [PATCH 0/3] Explicit CSI-2 LP-11 / LP-111 support Sakari Ailus
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).