]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/staging/greybus/gb-camera.h
net: add netlink_ext_ack argument to rtnl_link_ops.validate
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / greybus / gb-camera.h
CommitLineData
fc0ddf5a
GR
1/*
2 * Greybus Camera protocol driver.
3 *
4 * Copyright 2015 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */
8#ifndef __GB_CAMERA_H
9#define __GB_CAMERA_H
10
11#include <linux/v4l2-mediabus.h>
12
24ac4fa4
GR
13/* Input flags need to be set from the caller */
14#define GB_CAMERA_IN_FLAG_TEST (1 << 0)
15/* Output flags returned */
16#define GB_CAMERA_OUT_FLAG_ADJUSTED (1 << 0)
17
07f91c75
EB
18/**
19 * struct gb_camera_stream - Represents greybus camera stream.
20 * @width: Stream width in pixels.
21 * @height: Stream height in pixels.
22 * @pixel_code: Media bus pixel code.
23 * @vc: MIPI CSI virtual channel.
24 * @dt: MIPI CSI data types. Most formats use a single data type, in which case
25 * the second element will be ignored.
26 * @max_size: Maximum size of a frame in bytes. The camera module guarantees
27 * that all data between the Frame Start and Frame End packet for
28 * the associated virtual channel and data type(s) will not exceed
29 * this size.
30 */
fc0ddf5a
GR
31struct gb_camera_stream {
32 unsigned int width;
33 unsigned int height;
34 enum v4l2_mbus_pixelcode pixel_code;
35 unsigned int vc;
36 unsigned int dt[2];
37 unsigned int max_size;
38};
39
b4905038
EB
40/**
41 * struct gb_camera_csi_params - CSI configuration parameters
07f91c75
EB
42 * @num_lanes: number of CSI data lanes
43 * @clk_freq: CSI clock frequency in Hz
b4905038
EB
44 */
45struct gb_camera_csi_params {
46 unsigned int num_lanes;
47 unsigned int clk_freq;
b4905038
EB
48};
49
07f91c75
EB
50/**
51 * struct gb_camera_ops - Greybus camera operations, used by the Greybus camera
52 * driver to expose operations to the host camera driver.
53 * @capabilities: Retrieve camera capabilities and store them in the buffer
54 * 'buf' capabilities. The buffer maximum size is specified by
55 * the caller in the 'size' parameter, and the effective
56 * capabilities size is returned from the function. If the buffer
57 * size is too small to hold the capabilities an error is
58 * returned and the buffer is left untouched.
59 *
60 * @configure_streams: Negotiate configuration and prepare the module for video
61 * capture. The caller specifies the number of streams it
62 * requests in the 'nstreams' argument and the associated
63 * streams configurations in the 'streams' argument. The
64 * GB_CAMERA_IN_FLAG_TEST 'flag' can be set to test a
65 * configuration without applying it, otherwise the
66 * configuration is applied by the module. The module can
67 * decide to modify the requested configuration, including
68 * using a different number of streams. In that case the
69 * modified configuration won't be applied, the
70 * GB_CAMERA_OUT_FLAG_ADJUSTED 'flag' will be set upon
71 * return, and the modified configuration and number of
72 * streams stored in 'streams' and 'array'. The module
73 * returns its CSI-2 bus parameters in the 'csi_params'
74 * structure in all cases.
75 *
76 * @capture: Submit a capture request. The supplied 'request_id' must be unique
77 * and higher than the IDs of all the previously submitted requests.
78 * The 'streams' argument specifies which streams are affected by the
79 * request in the form of a bitmask, with bits corresponding to the
80 * configured streams indexes. If the request contains settings, the
81 * 'settings' argument points to the settings buffer and its size is
82 * specified by the 'settings_size' argument. Otherwise the 'settings'
83 * argument should be set to NULL and 'settings_size' to 0.
84 *
85 * @flush: Flush the capture requests queue. Return the ID of the last request
86 * that will processed by the device before it stops transmitting video
87 * frames. All queued capture requests with IDs higher than the returned
88 * ID will be dropped without being processed.
89 */
fc0ddf5a
GR
90struct gb_camera_ops {
91 ssize_t (*capabilities)(void *priv, char *buf, size_t len);
24ac4fa4 92 int (*configure_streams)(void *priv, unsigned int *nstreams,
b4905038
EB
93 unsigned int *flags, struct gb_camera_stream *streams,
94 struct gb_camera_csi_params *csi_params);
fc0ddf5a
GR
95 int (*capture)(void *priv, u32 request_id,
96 unsigned int streams, unsigned int num_frames,
97 size_t settings_size, const void *settings);
98 int (*flush)(void *priv, u32 *request_id);
99};
100
07f91c75
EB
101/**
102 * struct gb_camera_module - Represents greybus camera module.
103 * @priv: Module private data, passed to all camera operations.
104 * @ops: Greybus camera operation callbacks.
6c5ce637
EB
105 * @interface_id: Interface id of the module.
106 * @refcount: Reference counting object.
107 * @release: Module release function.
07f91c75
EB
108 * @list: List entry in the camera modules list.
109 */
c3d77f71
GR
110struct gb_camera_module {
111 void *priv;
1472ec67 112 const struct gb_camera_ops *ops;
fc0ddf5a 113
6c5ce637
EB
114 unsigned int interface_id;
115 struct kref refcount;
116 void (*release)(struct kref *kref);
c3d77f71
GR
117 struct list_head list; /* Global list */
118};
119
120#define gb_camera_call(f, op, args...) \
1472ec67
GR
121 (!(f) ? -ENODEV : (((f)->ops->op) ? \
122 (f)->ops->op((f)->priv, ##args) : -ENOIOCTLCMD))
c3d77f71
GR
123
124int gb_camera_register(struct gb_camera_module *module);
125int gb_camera_unregister(struct gb_camera_module *module);
fc0ddf5a
GR
126
127#endif /* __GB_CAMERA_H */