Commit 48b15a9b authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Greg Kroah-Hartman

greybus: camera: Implement the capabilities operation

The operation queries the camera module for its capabilities. The
debugfs interface just prints a hex dump of the binary message.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarJacopo Mondi <jacopo.mondi@linaro.org>
Reviewed-by: default avatarGjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent f8811c76
......@@ -156,6 +156,33 @@ static int gb_camera_set_power_mode(struct gb_camera *gcam, bool hs)
return 0;
}
static int gb_camera_capabilities(struct gb_camera *gcam,
u8 *capabilities, size_t *size)
{
struct gb_operation *op;
int ret;
op = gb_operation_create_flags(gcam->connection,
GB_CAMERA_TYPE_CAPABILITIES, 0, *size,
GB_OPERATION_FLAG_SHORT_RESPONSE,
GFP_KERNEL);
if (!op)
return -ENOMEM;
ret = gb_operation_request_send_sync(op);
if (ret) {
gcam_err(gcam, "failed to retrieve capabilities: %d\n", ret);
goto done;
}
memcpy(capabilities, op->response->payload, op->response->payload_size);
*size = op->response->payload_size;
done:
gb_operation_put(op);
return ret;
}
struct ap_csi_config_request {
__u8 csi_id;
__u8 flags;
......@@ -478,10 +505,41 @@ static int gb_camera_register_intf_ops(struct gb_camera *gcam)
/* -----------------------------------------------------------------------------
* DebugFS
*/
static ssize_t gb_camera_debugfs_capabilities(struct gb_camera *gcam,
char *buf, size_t len)
{
return len;
struct gb_camera_debugfs_buffer *buffer =
&gcam->debugfs.buffers[GB_CAMERA_DEBUGFS_BUFFER_CAPABILITIES];
size_t size = 1024;
unsigned int i;
u8 *caps;
int ret;
caps = kmalloc(size, GFP_KERNEL);
if (!caps)
return -ENOMEM;
ret = gb_camera_capabilities(gcam, caps, &size);
if (ret < 0)
goto done;
/*
* hex_dump_to_buffer() doesn't return the number of bytes dumped prior
* to v4.0, we need our own implementation :-(
*/
buffer->length = 0;
for (i = 0; i < size; i += 16) {
unsigned int nbytes = min_t(unsigned int, size - i, 16);
buffer->length += sprintf(buffer->data + buffer->length,
"%*ph\n", nbytes, caps + i);
}
done:
kfree(caps);
return ret;
}
static ssize_t gb_camera_debugfs_configure_streams(struct gb_camera *gcam,
......
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