summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/gb-camera.h
blob: cc9c012249e23e203271510d3f39c6458f0b6440 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Greybus Camera protocol driver.
 *
 * Copyright 2015 Google Inc.
 *
 * Released under the GPLv2 only.
 */
#ifndef __GB_CAMERA_H
#define __GB_CAMERA_H

#include <linux/v4l2-mediabus.h>

/* Input flags need to be set from the caller */
#define GB_CAMERA_IN_FLAG_TEST		(1 << 0)
/* Output flags returned */
#define GB_CAMERA_OUT_FLAG_ADJUSTED	(1 << 0)

struct gb_camera_stream {
	unsigned int width;
	unsigned int height;
	enum v4l2_mbus_pixelcode pixel_code;
	unsigned int vc;
	unsigned int dt[2];
	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,
			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);
	int (*flush)(void *priv, u32 *request_id);
};

struct gb_camera_module {
	void *priv;
	const struct gb_camera_ops *ops;

	struct list_head list; /* Global list */
};

#define gb_camera_call(f, op, args...)      \
	(!(f) ? -ENODEV : (((f)->ops->op) ?  \
	(f)->ops->op((f)->priv, ##args) : -ENOIOCTLCMD))

int gb_camera_register(struct gb_camera_module *module);
int gb_camera_unregister(struct gb_camera_module *module);

#endif /* __GB_CAMERA_H */