Commit b787d413 authored by Jacopo Mondi's avatar Jacopo Mondi Committed by Greg Kroah-Hartman

greybus: camera: Add support for flags to stream_configure

Add support for the flags field of the stream configure request that was
recently added to the camera protocol and update the debugfs arguments
parsing accordingly. The stream configure response layout is also
updated to the latest protocol specification.
Signed-off-by: default avatarJacopo Mondi <jacopo.mondi@linaro.org>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent aab4a1a3
......@@ -76,6 +76,7 @@ struct gb_camera_stream_config {
static int gb_camera_configure_streams(struct gb_camera *gcam,
unsigned int nstreams,
unsigned int flags,
struct gb_camera_stream_config *streams)
{
struct gb_camera_configure_streams_request *req;
......@@ -99,7 +100,8 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
goto done;
}
req->num_streams = cpu_to_le16(nstreams);
req->num_streams = nstreams;
req->flags = flags;
req->padding = 0;
for (i = 0; i < nstreams; ++i) {
......@@ -117,9 +119,9 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
if (ret < 0)
goto done;
if (le16_to_cpu(resp->num_streams) > nstreams) {
if (resp->num_streams > nstreams) {
gcam_dbg(gcam, "got #streams %u > request %u\n",
le16_to_cpu(resp->num_streams), nstreams);
resp->num_streams, nstreams);
ret = -EIO;
goto done;
}
......@@ -169,7 +171,7 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
gcam_err(gcam, "failed to %s the CSI transmitter\n",
nstreams ? "start" : "stop");
ret = le16_to_cpu(resp->num_streams);
ret = resp->num_streams;
done:
kfree(req);
......@@ -266,13 +268,13 @@ static ssize_t gb_camera_debugfs_configure_streams(struct gb_camera *gcam,
&gcam->debugfs.buffers[GB_CAMERA_DEBUGFS_BUFFER_STREAMS];
struct gb_camera_stream_config *streams;
unsigned int nstreams;
const char *sep = ";";
unsigned int flags;
unsigned int i;
char *token;
int ret;
/* Retrieve number of streams to configure */
token = strsep(&buf, sep);
token = strsep(&buf, ";");
if (token == NULL)
return -EINVAL;
......@@ -283,6 +285,14 @@ static ssize_t gb_camera_debugfs_configure_streams(struct gb_camera *gcam,
if (nstreams > GB_CAMERA_MAX_STREAMS)
return -EINVAL;
token = strsep(&buf, ";");
if (token == NULL)
return -EINVAL;
ret = kstrtouint(token, 10, &flags);
if (ret < 0)
return ret;
/* For each stream to configure parse width, height and format */
streams = kzalloc(nstreams * sizeof(*streams), GFP_KERNEL);
if (!streams)
......@@ -320,7 +330,7 @@ static ssize_t gb_camera_debugfs_configure_streams(struct gb_camera *gcam,
goto done;
}
ret = gb_camera_configure_streams(gcam, nstreams, streams);
ret = gb_camera_configure_streams(gcam, nstreams, flags, streams);
if (ret < 0)
goto done;
......
......@@ -1173,7 +1173,9 @@ struct gb_camera_stream_config_request {
} __packed;
struct gb_camera_configure_streams_request {
__le16 num_streams;
__u8 num_streams;
__u8 flags;
#define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY 0x01
__le16 padding;
struct gb_camera_stream_config_request config[0];
} __packed;
......@@ -1190,10 +1192,10 @@ struct gb_camera_stream_config_response {
} __packed;
struct gb_camera_configure_streams_response {
__le16 num_streams;
#define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01
__u8 num_streams;
__u8 flags;
__u8 padding;
#define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01
__le16 padding;
struct gb_camera_stream_config_response config[0];
} __packed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment