@@ -42,6 +42,12 @@
int v4l2_subdev_open(struct media_entity *entity)
{
+ struct v4l2_subdev_client_capability clientcap = {};
+ struct v4l2_subdev_capability subdevcap = {};
+ bool subdev_streams;
+ bool client_streams;
+ int ret;
+
if (entity->fd != -1)
return 0;
@@ -54,6 +60,16 @@ int v4l2_subdev_open(struct media_entity *entity)
return ret;
}
+ ret = ioctl(entity->fd, VIDIOC_SUBDEV_QUERYCAP, &subdevcap);
+ subdev_streams = !ret && (subdevcap.capabilities & V4L2_SUBDEV_CAP_STREAMS);
+
+ clientcap.capabilities = V4L2_SUBDEV_CLIENT_CAP_STREAMS;
+
+ ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_CLIENT_CAP, &clientcap);
+ client_streams = !ret && (clientcap.capabilities & V4L2_SUBDEV_CLIENT_CAP_STREAMS);
+
+ entity->supports_streams = subdev_streams && client_streams;
+
return 0;
}
@@ -74,6 +90,11 @@ int v4l2_subdev_get_format(struct media_entity *entity,
if (ret < 0)
return ret;
+ if (!entity->supports_streams && stream) {
+ media_dbg(entity->media, "Streams API not supported\n");
+ return -ENOTSUP;
+ }
+
memset(&fmt, 0, sizeof(fmt));
fmt.pad = pad;
fmt.stream = stream;
@@ -99,6 +120,11 @@ int v4l2_subdev_set_format(struct media_entity *entity,
if (ret < 0)
return ret;
+ if (!entity->supports_streams && stream) {
+ media_dbg(entity->media, "Streams API not supported\n");
+ return -ENOTSUP;
+ }
+
memset(&fmt, 0, sizeof(fmt));
fmt.pad = pad;
fmt.stream = stream;
@@ -127,6 +153,11 @@ int v4l2_subdev_get_selection(struct media_entity *entity,
if (ret < 0)
return ret;
+ if (!entity->supports_streams && stream) {
+ media_dbg(entity->media, "Streams API not supported\n");
+ return -ENOTSUP;
+ }
+
memset(&u.sel, 0, sizeof(u.sel));
u.sel.pad = pad;
u.sel.target = target;
@@ -166,6 +197,11 @@ int v4l2_subdev_set_selection(struct media_entity *entity,
if (ret < 0)
return ret;
+ if (!entity->supports_streams && stream) {
+ media_dbg(entity->media, "Streams API not supported\n");
+ return -ENOTSUP;
+ }
+
memset(&u.sel, 0, sizeof(u.sel));
u.sel.pad = pad;
u.sel.stream = stream;
@@ -209,6 +245,11 @@ int v4l2_subdev_get_routing(struct media_entity *entity,
if (ret < 0)
return ret;
+ if (!entity->supports_streams) {
+ media_dbg(entity->media, "Streams API not supported\n");
+ return -ENOTSUP;
+ }
+
ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_ROUTING, &routing);
if (ret == -1 && errno != ENOSPC)
return -errno;
@@ -251,6 +292,11 @@ int v4l2_subdev_set_routing(struct media_entity *entity,
if (ret < 0)
return ret;
+ if (!entity->supports_streams) {
+ media_dbg(entity->media, "Streams API not supported\n");
+ return -ENOTSUP;
+ }
+
ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_ROUTING, &routing);
if (ret == -1)
return -errno;
@@ -341,6 +387,11 @@ int v4l2_subdev_get_frame_interval(struct media_entity *entity,
if (ret < 0)
return ret;
+ if (!entity->supports_streams && stream) {
+ media_dbg(entity->media, "Streams API not supported\n");
+ return -ENOTSUP;
+ }
+
memset(&ival, 0, sizeof(ival));
ival.pad = pad;
ival.stream = stream;
@@ -364,6 +415,11 @@ int v4l2_subdev_set_frame_interval(struct media_entity *entity,
if (ret < 0)
return ret;
+ if (!entity->supports_streams && stream) {
+ media_dbg(entity->media, "Streams API not supported\n");
+ return -ENOTSUP;
+ }
+
memset(&ival, 0, sizeof(ival));
ival.pad = pad;
ival.stream = stream;
@@ -33,6 +33,7 @@ struct media_entity {
struct media_link *links;
unsigned int max_links;
unsigned int num_links;
+ bool supports_streams;
char devname[32];
int fd;