From b787d413e0d99ae74e21cdab600ea3c5b0886ec2 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 8 Jan 2016 18:13:20 +0200 Subject: [PATCH] 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: Jacopo Mondi Signed-off-by: Laurent Pinchart Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/camera.c | 24 +++++++++++++++------ drivers/staging/greybus/greybus_protocols.h | 10 +++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c index 4e96e1fcfcdf..06ea5293d389 100644 --- a/drivers/staging/greybus/camera.c +++ b/drivers/staging/greybus/camera.c @@ -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; diff --git a/drivers/staging/greybus/greybus_protocols.h b/drivers/staging/greybus/greybus_protocols.h index 72e753c697aa..67f260beba63 100644 --- a/drivers/staging/greybus/greybus_protocols.h +++ b/drivers/staging/greybus/greybus_protocols.h @@ -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; -- 2.20.1