Revert "media: subdev: Improve v4l2_subdev_enable/disable_streams_fallback"
This reverts commit 2b3dc697a4
which is
commit 61d6c8c896c1ccde350c281817847a32b0c6b83b upstream.
It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.
Bug: 161946584
Change-Id: I6b03604c6b43baba83e71cc1af61243813370d33
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
@@ -1925,43 +1925,37 @@ static int v4l2_subdev_enable_streams_fallback(struct v4l2_subdev *sd, u32 pad,
|
||||
u64 streams_mask)
|
||||
{
|
||||
struct device *dev = sd->entity.graph_obj.mdev->dev;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* The subdev doesn't implement pad-based stream enable, fall back
|
||||
* to the .s_stream() operation.
|
||||
* on the .s_stream() operation. This can only be done for subdevs that
|
||||
* have a single source pad, as sd->enabled_streams is global to the
|
||||
* subdev.
|
||||
*/
|
||||
if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/*
|
||||
* .s_stream() means there is no streams support, so the only allowed
|
||||
* stream is the implicit stream 0.
|
||||
*/
|
||||
if (streams_mask != BIT_ULL(0))
|
||||
return -EOPNOTSUPP;
|
||||
for (i = 0; i < sd->entity.num_pads; ++i) {
|
||||
if (i != pad && sd->entity.pads[i].flags & MEDIA_PAD_FL_SOURCE)
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/*
|
||||
* We use a 64-bit bitmask for tracking enabled pads, so only subdevices
|
||||
* with 64 pads or less can be supported.
|
||||
*/
|
||||
if (pad >= sizeof(sd->enabled_pads) * BITS_PER_BYTE)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (sd->enabled_pads & BIT_ULL(pad)) {
|
||||
dev_dbg(dev, "pad %u already enabled on %s\n",
|
||||
pad, sd->entity.name);
|
||||
if (sd->enabled_streams & streams_mask) {
|
||||
dev_dbg(dev, "set of streams %#llx already enabled on %s:%u\n",
|
||||
streams_mask, sd->entity.name, pad);
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
/* Start streaming when the first pad is enabled. */
|
||||
if (!sd->enabled_pads) {
|
||||
/* Start streaming when the first streams are enabled. */
|
||||
if (!sd->enabled_streams) {
|
||||
ret = v4l2_subdev_call(sd, video, s_stream, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
sd->enabled_pads |= BIT_ULL(pad);
|
||||
sd->enabled_streams |= streams_mask;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2048,43 +2042,37 @@ static int v4l2_subdev_disable_streams_fallback(struct v4l2_subdev *sd, u32 pad,
|
||||
u64 streams_mask)
|
||||
{
|
||||
struct device *dev = sd->entity.graph_obj.mdev->dev;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* If the subdev doesn't implement pad-based stream enable, fall back
|
||||
* to the .s_stream() operation.
|
||||
* If the subdev doesn't implement pad-based stream enable, fall back
|
||||
* on the .s_stream() operation. This can only be done for subdevs that
|
||||
* have a single source pad, as sd->enabled_streams is global to the
|
||||
* subdev.
|
||||
*/
|
||||
if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/*
|
||||
* .s_stream() means there is no streams support, so the only allowed
|
||||
* stream is the implicit stream 0.
|
||||
*/
|
||||
if (streams_mask != BIT_ULL(0))
|
||||
return -EOPNOTSUPP;
|
||||
for (i = 0; i < sd->entity.num_pads; ++i) {
|
||||
if (i != pad && sd->entity.pads[i].flags & MEDIA_PAD_FL_SOURCE)
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/*
|
||||
* We use a 64-bit bitmask for tracking enabled pads, so only subdevices
|
||||
* with 64 pads or less can be supported.
|
||||
*/
|
||||
if (pad >= sizeof(sd->enabled_pads) * BITS_PER_BYTE)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (!(sd->enabled_pads & BIT_ULL(pad))) {
|
||||
dev_dbg(dev, "pad %u already disabled on %s\n",
|
||||
pad, sd->entity.name);
|
||||
if ((sd->enabled_streams & streams_mask) != streams_mask) {
|
||||
dev_dbg(dev, "set of streams %#llx already disabled on %s:%u\n",
|
||||
streams_mask, sd->entity.name, pad);
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
/* Stop streaming when the last streams are disabled. */
|
||||
if (!(sd->enabled_pads & ~BIT_ULL(pad))) {
|
||||
if (!(sd->enabled_streams & ~streams_mask)) {
|
||||
ret = v4l2_subdev_call(sd, video, s_stream, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
sd->enabled_pads &= ~BIT_ULL(pad);
|
||||
sd->enabled_streams &= ~streams_mask;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1038,9 +1038,10 @@ struct v4l2_subdev_platform_data {
|
||||
* @active_state: Active state for the subdev (NULL for subdevs tracking the
|
||||
* state internally). Initialized by calling
|
||||
* v4l2_subdev_init_finalize().
|
||||
* @enabled_pads: Bitmask of enabled pads used by v4l2_subdev_enable_streams()
|
||||
* and v4l2_subdev_disable_streams() helper functions for
|
||||
* fallback cases.
|
||||
* @enabled_streams: Bitmask of enabled streams used by
|
||||
* v4l2_subdev_enable_streams() and
|
||||
* v4l2_subdev_disable_streams() helper functions for fallback
|
||||
* cases.
|
||||
* @s_stream_enabled: Tracks whether streaming has been enabled with s_stream.
|
||||
* This is only for call_s_stream() internal use.
|
||||
*
|
||||
@@ -1090,7 +1091,7 @@ struct v4l2_subdev {
|
||||
* doesn't support it.
|
||||
*/
|
||||
struct v4l2_subdev_state *active_state;
|
||||
u64 enabled_pads;
|
||||
u64 enabled_streams;
|
||||
bool s_stream_enabled;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user