Skip to content

Commit 805d431

Browse files
pinchartlHans Verkuil
authored andcommitted
media: v4l2-subdev: Add which field to struct v4l2_subdev_frame_interval
Due to a historical mishap, the v4l2_subdev_frame_interval structure is the only part of the V4L2 subdev userspace API that doesn't contain a 'which' field. This prevents trying frame intervals using the subdev 'TRY' state mechanism. Adding a 'which' field is simple as the structure has 8 reserved fields. This would however break userspace as the field is currently set to 0, corresponding to V4L2_SUBDEV_FORMAT_TRY, while the corresponding ioctls currently operate on the 'ACTIVE' state. We thus need to add a new subdev client cap, V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH, to indicate that userspace is aware of this new field. All drivers that implement the subdev .get_frame_interval() and .set_frame_interval() operations are updated to return -EINVAL when operating on the TRY state, preserving the current behaviour. While at it, fix a bad copy&paste in the documentation of the struct v4l2_subdev_frame_interval_enum 'which' field. Signed-off-by: Laurent Pinchart <[email protected]> Reviewed-by: Philipp Zabel <[email protected]> # for imx-media Reviewed-by: Hans Verkuil <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> # for tegra-video Reviewed-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 287fe16 commit 805d431

37 files changed

+425
-18
lines changed

Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ is unknown to the kernel.
7171
of 'stream' fields (referring to the stream number) with various
7272
ioctls. If this is not set (which is the default), the 'stream' fields
7373
will be forced to 0 by the kernel.
74+
* - ``V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH``
75+
- The client is aware of the :c:type:`v4l2_subdev_frame_interval`
76+
``which`` field. If this is not set (which is the default), the
77+
``which`` field is forced to ``V4L2_SUBDEV_FORMAT_ACTIVE`` by the
78+
kernel.
7479

7580
Return Value
7681
============

Documentation/userspace-api/media/v4l/vidioc-subdev-g-frame-interval.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ struct
5858
contains the current frame interval as would be returned by a
5959
``VIDIOC_SUBDEV_G_FRAME_INTERVAL`` call.
6060

61-
Calling ``VIDIOC_SUBDEV_S_FRAME_INTERVAL`` on a subdev device node that has been
62-
registered in read-only mode is not allowed. An error is returned and the errno
61+
If the subdev device node has been registered in read-only mode, calls to
62+
``VIDIOC_SUBDEV_S_FRAME_INTERVAL`` are only valid if the ``which`` field is set
63+
to ``V4L2_SUBDEV_FORMAT_TRY``, otherwise an error is returned and the errno
6364
variable is set to ``-EPERM``.
6465

6566
Drivers must not return an error solely because the requested interval
@@ -93,7 +94,11 @@ the same sub-device is not defined.
9394
- ``stream``
9495
- Stream identifier.
9596
* - __u32
96-
- ``reserved``\ [8]
97+
- ``which``
98+
- Active or try frame interval, from enum
99+
:ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
100+
* - __u32
101+
- ``reserved``\ [7]
97102
- Reserved for future extensions. Applications and drivers must set
98103
the array to zero.
99104

@@ -114,9 +119,9 @@ EBUSY
114119
EINVAL
115120
The struct
116121
:c:type:`v4l2_subdev_frame_interval`
117-
``pad`` references a non-existing pad, or the pad doesn't support
118-
frame intervals.
122+
``pad`` references a non-existing pad, the ``which`` field references a
123+
non-existing frame interval, or the pad doesn't support frame intervals.
119124

120125
EPERM
121126
The ``VIDIOC_SUBDEV_S_FRAME_INTERVAL`` ioctl has been called on a read-only
122-
subdevice.
127+
subdevice and the ``which`` field is set to ``V4L2_SUBDEV_FORMAT_ACTIVE``.

drivers/media/i2c/adv7180.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,13 @@ static int adv7180_get_frame_interval(struct v4l2_subdev *sd,
469469
{
470470
struct adv7180_state *state = to_state(sd);
471471

472+
/*
473+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
474+
* subdev active state API.
475+
*/
476+
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
477+
return -EINVAL;
478+
472479
if (state->curr_norm & V4L2_STD_525_60) {
473480
fi->interval.numerator = 1001;
474481
fi->interval.denominator = 30000;

drivers/media/i2c/alvium-csi2.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,13 @@ static int alvium_g_frame_interval(struct v4l2_subdev *sd,
16541654
{
16551655
struct alvium_dev *alvium = sd_to_alvium(sd);
16561656

1657+
/*
1658+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1659+
* subdev active state API.
1660+
*/
1661+
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1662+
return -EINVAL;
1663+
16571664
fi->interval = alvium->frame_interval;
16581665

16591666
return 0;
@@ -1703,6 +1710,13 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd,
17031710
struct alvium_dev *alvium = sd_to_alvium(sd);
17041711
int ret;
17051712

1713+
/*
1714+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1715+
* subdev active state API.
1716+
*/
1717+
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1718+
return -EINVAL;
1719+
17061720
if (alvium->streaming)
17071721
return -EBUSY;
17081722

drivers/media/i2c/et8ek8/et8ek8_driver.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,13 @@ static int et8ek8_get_frame_interval(struct v4l2_subdev *subdev,
10511051
{
10521052
struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
10531053

1054+
/*
1055+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1056+
* subdev active state API.
1057+
*/
1058+
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1059+
return -EINVAL;
1060+
10541061
memset(fi, 0, sizeof(*fi));
10551062
fi->interval = sensor->current_reglist->mode.timeperframe;
10561063

@@ -1064,6 +1071,13 @@ static int et8ek8_set_frame_interval(struct v4l2_subdev *subdev,
10641071
struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev);
10651072
struct et8ek8_reglist *reglist;
10661073

1074+
/*
1075+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1076+
* subdev active state API.
1077+
*/
1078+
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1079+
return -EINVAL;
1080+
10671081
reglist = et8ek8_reglist_find_mode_ival(&meta_reglist,
10681082
sensor->current_reglist,
10691083
&fi->interval);

drivers/media/i2c/imx214.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,13 @@ static int imx214_get_frame_interval(struct v4l2_subdev *subdev,
905905
struct v4l2_subdev_state *sd_state,
906906
struct v4l2_subdev_frame_interval *fival)
907907
{
908+
/*
909+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
910+
* subdev active state API.
911+
*/
912+
if (fival->which != V4L2_SUBDEV_FORMAT_ACTIVE)
913+
return -EINVAL;
914+
908915
fival->interval.numerator = 1;
909916
fival->interval.denominator = IMX214_FPS;
910917

drivers/media/i2c/imx274.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,13 @@ static int imx274_get_frame_interval(struct v4l2_subdev *sd,
13331333
{
13341334
struct stimx274 *imx274 = to_imx274(sd);
13351335

1336+
/*
1337+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1338+
* subdev active state API.
1339+
*/
1340+
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1341+
return -EINVAL;
1342+
13361343
fi->interval = imx274->frame_interval;
13371344
dev_dbg(&imx274->client->dev, "%s frame rate = %d / %d\n",
13381345
__func__, imx274->frame_interval.numerator,
@@ -1350,6 +1357,13 @@ static int imx274_set_frame_interval(struct v4l2_subdev *sd,
13501357
int min, max, def;
13511358
int ret;
13521359

1360+
/*
1361+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1362+
* subdev active state API.
1363+
*/
1364+
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1365+
return -EINVAL;
1366+
13531367
ret = pm_runtime_resume_and_get(&imx274->client->dev);
13541368
if (ret < 0)
13551369
return ret;

drivers/media/i2c/max9286.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,13 @@ static int max9286_get_frame_interval(struct v4l2_subdev *sd,
874874
{
875875
struct max9286_priv *priv = sd_to_max9286(sd);
876876

877+
/*
878+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
879+
* subdev active state API.
880+
*/
881+
if (interval->which != V4L2_SUBDEV_FORMAT_ACTIVE)
882+
return -EINVAL;
883+
877884
if (interval->pad != MAX9286_SRC_PAD)
878885
return -EINVAL;
879886

@@ -888,6 +895,13 @@ static int max9286_set_frame_interval(struct v4l2_subdev *sd,
888895
{
889896
struct max9286_priv *priv = sd_to_max9286(sd);
890897

898+
/*
899+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
900+
* subdev active state API.
901+
*/
902+
if (interval->which != V4L2_SUBDEV_FORMAT_ACTIVE)
903+
return -EINVAL;
904+
891905
if (interval->pad != MAX9286_SRC_PAD)
892906
return -EINVAL;
893907

drivers/media/i2c/mt9m111.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,13 @@ static int mt9m111_get_frame_interval(struct v4l2_subdev *sd,
10511051
{
10521052
struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
10531053

1054+
/*
1055+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1056+
* subdev active state API.
1057+
*/
1058+
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1059+
return -EINVAL;
1060+
10541061
fi->interval = mt9m111->frame_interval;
10551062

10561063
return 0;
@@ -1068,6 +1075,13 @@ static int mt9m111_set_frame_interval(struct v4l2_subdev *sd,
10681075
if (mt9m111->is_streaming)
10691076
return -EBUSY;
10701077

1078+
/*
1079+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1080+
* subdev active state API.
1081+
*/
1082+
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1083+
return -EINVAL;
1084+
10711085
if (fi->pad != 0)
10721086
return -EINVAL;
10731087

drivers/media/i2c/mt9m114.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,13 @@ static int mt9m114_ifp_get_frame_interval(struct v4l2_subdev *sd,
15921592
struct v4l2_fract *ival = &interval->interval;
15931593
struct mt9m114 *sensor = ifp_to_mt9m114(sd);
15941594

1595+
/*
1596+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1597+
* subdev active state API.
1598+
*/
1599+
if (interval->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1600+
return -EINVAL;
1601+
15951602
mutex_lock(sensor->ifp.hdl.lock);
15961603

15971604
ival->numerator = 1;
@@ -1610,6 +1617,13 @@ static int mt9m114_ifp_set_frame_interval(struct v4l2_subdev *sd,
16101617
struct mt9m114 *sensor = ifp_to_mt9m114(sd);
16111618
int ret = 0;
16121619

1620+
/*
1621+
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
1622+
* subdev active state API.
1623+
*/
1624+
if (interval->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1625+
return -EINVAL;
1626+
16131627
mutex_lock(sensor->ifp.hdl.lock);
16141628

16151629
if (ival->numerator != 0 && ival->denominator != 0)

0 commit comments

Comments
 (0)