greybus: camera-gb: Extend the configure streams interface
authorEvgeniy Borisov <borisov_evgeniy@projectara.com>
Wed, 6 Apr 2016 12:22:45 +0000 (15:22 +0300)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 12 Apr 2016 01:47:57 +0000 (18:47 -0700)
Extending the configure streams interface with CSI params.
Getting CSI frequency data form configure streams response.
 * num_lanes - Number of CSI data lanes
 * clk_freq - CSI clock frequency in Hz
 * lines_per_second - Total number of lines in a second of
transmission (blanking included)

From the AP side we need to know for the CSI speed
configuration. This information is needed for dynamically
bandwidth calculations.

NOTE: Change should be along merged with corresponding
      interface change in kernel:
      "camera: Extend the configure streams
      interface with CSI params"

Signed-off-by: Evgeniy Borisov <eborisov@mm-sol.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/camera.c
drivers/staging/greybus/gb-camera.h

index 6db89efb8f0e16ef8f94a1969b627837ff1d53e4..d3ee5b7240db0060ac8bf0c7b6d1e77f2caea809 100644 (file)
@@ -203,7 +203,8 @@ struct ap_csi_config_request {
 static int gb_camera_configure_streams(struct gb_camera *gcam,
                                       unsigned int *num_streams,
                                       unsigned int *flags,
-                                      struct gb_camera_stream_config *streams)
+                                      struct gb_camera_stream_config *streams,
+                                      struct gb_camera_csi_params *csi_params)
 {
        struct gb_camera_configure_streams_request *req;
        struct gb_camera_configure_streams_response *resp;
@@ -309,6 +310,12 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
                ret = gb_hd_output(gcam->connection->hd, &csi_cfg,
                                   sizeof(csi_cfg),
                                   GB_APB_REQUEST_CSI_TX_CONTROL, false);
+               if (csi_params) {
+                       csi_params->num_lanes = csi_cfg.num_lanes;
+                       /* Transmitting two bits per cycle. (DDR clock) */
+                       csi_params->clk_freq = csi_cfg.bus_freq / 2;
+                       csi_params->lines_per_second = csi_cfg.lines_per_second;
+               }
        } else {
                csi_cfg.csi_id = 1;
                ret = gb_hd_output(gcam->connection->hd, &csi_cfg,
@@ -442,7 +449,8 @@ static ssize_t gb_camera_op_capabilities(void *priv, char *data, size_t len)
 }
 
 static int gb_camera_op_configure_streams(void *priv, unsigned int *nstreams,
-               unsigned int *flags, struct gb_camera_stream *streams)
+               unsigned int *flags, struct gb_camera_stream *streams,
+               struct gb_camera_csi_params *csi_params)
 {
        struct gb_camera *gcam = priv;
        struct gb_camera_stream_config *gb_streams;
@@ -469,7 +477,7 @@ static int gb_camera_op_configure_streams(void *priv, unsigned int *nstreams,
                gb_flags |= GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY;
 
        ret = gb_camera_configure_streams(gcam, &gb_nstreams,
-                                         &gb_flags, gb_streams);
+                                         &gb_flags, gb_streams, csi_params);
        if (ret < 0)
                goto done;
        if (gb_nstreams > *nstreams) {
@@ -643,7 +651,8 @@ static ssize_t gb_camera_debugfs_configure_streams(struct gb_camera *gcam,
                        goto done;
        }
 
-       ret = gb_camera_configure_streams(gcam, &nstreams, &flags, streams);
+       ret = gb_camera_configure_streams(gcam, &nstreams, &flags, streams,
+                                         NULL);
        if (ret < 0)
                goto done;
 
index 273b4fa6dd4f2bde188d86f18a19a19f19d1871f..cc9c012249e23e203271510d3f39c6458f0b6440 100644 (file)
@@ -24,10 +24,24 @@ struct gb_camera_stream {
        unsigned int max_size;
 };
 
+/**
+ * struct gb_camera_csi_params - CSI configuration parameters
+ * @num_lanes:         number of CSI data lanes
+ * @clk_freq:          CSI clock frequency in Hz
+ * @lines_per_second:  total number of lines in a second of transmission
+ *                     (blanking included)
+ */
+struct gb_camera_csi_params {
+       unsigned int num_lanes;
+       unsigned int clk_freq;
+       unsigned int lines_per_second;
+};
+
 struct gb_camera_ops {
        ssize_t (*capabilities)(void *priv, char *buf, size_t len);
        int (*configure_streams)(void *priv, unsigned int *nstreams,
-                       unsigned int *flags, struct gb_camera_stream *streams);
+                       unsigned int *flags, struct gb_camera_stream *streams,
+                       struct gb_camera_csi_params *csi_params);
        int (*capture)(void *priv, u32 request_id,
                        unsigned int streams, unsigned int num_frames,
                        size_t settings_size, const void *settings);