sch_tbf: fix two null pointer dereferences on init failure
[linux-2.6/btrfs-unstable.git] / drivers / staging / greybus / gb-camera.h
blobd45dabc5b3679303c445546210b9754239df3d53
1 /*
2 * Greybus Camera protocol driver.
4 * Copyright 2015 Google Inc.
6 * Released under the GPLv2 only.
7 */
8 #ifndef __GB_CAMERA_H
9 #define __GB_CAMERA_H
11 #include <linux/v4l2-mediabus.h>
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)
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.
31 struct 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;
40 /**
41 * struct gb_camera_csi_params - CSI configuration parameters
42 * @num_lanes: number of CSI data lanes
43 * @clk_freq: CSI clock frequency in Hz
45 struct gb_camera_csi_params {
46 unsigned int num_lanes;
47 unsigned int clk_freq;
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.
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.
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.
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.
90 struct gb_camera_ops {
91 ssize_t (*capabilities)(void *priv, char *buf, size_t len);
92 int (*configure_streams)(void *priv, unsigned int *nstreams,
93 unsigned int *flags, struct gb_camera_stream *streams,
94 struct gb_camera_csi_params *csi_params);
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);
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.
105 * @interface_id: Interface id of the module.
106 * @refcount: Reference counting object.
107 * @release: Module release function.
108 * @list: List entry in the camera modules list.
110 struct gb_camera_module {
111 void *priv;
112 const struct gb_camera_ops *ops;
114 unsigned int interface_id;
115 struct kref refcount;
116 void (*release)(struct kref *kref);
117 struct list_head list; /* Global list */
120 #define gb_camera_call(f, op, args...) \
121 (!(f) ? -ENODEV : (((f)->ops->op) ? \
122 (f)->ops->op((f)->priv, ##args) : -ENOIOCTLCMD))
124 int gb_camera_register(struct gb_camera_module *module);
125 int gb_camera_unregister(struct gb_camera_module *module);
127 #endif /* __GB_CAMERA_H */