1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef QC_MSM_CAMSS_H
19#define QC_MSM_CAMSS_H
20
21#include <linux/types.h>
22#include <media/v4l2-async.h>
23#include <media/v4l2-device.h>
24#include <media/v4l2-subdev.h>
25#include <media/media-device.h>
26#include <media/media-entity.h>
27#include <linux/device.h>
28
29#include "camss-csid.h"
30#include "camss-csiphy.h"
31#include "camss-ispif.h"
32#include "camss-vfe.h"
33
34#define CAMSS_CSID_NUM 2
35#define CAMSS_CSIPHY_NUM 2
36
37#define to_camss(ptr_module) \
38 container_of(ptr_module, struct camss, ptr_module)
39
40#define to_device(ptr_module) \
41 (to_camss(ptr_module)->dev)
42
43#define module_pointer(ptr_module, index) \
44 ((const struct ptr_module##_device (*)[]) &(ptr_module[-(index)]))
45
46#define to_camss_index(ptr_module, index) \
47 container_of(module_pointer(ptr_module, index), \
48 struct camss, ptr_module)
49
50#define to_device_index(ptr_module, index) \
51 (to_camss_index(ptr_module, index)->dev)
52
53#define CAMSS_RES_MAX 15
54
55struct resources {
56 char *regulator[CAMSS_RES_MAX];
57 char *clock[CAMSS_RES_MAX];
58 u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX];
59 char *reg[CAMSS_RES_MAX];
60 char *interrupt[CAMSS_RES_MAX];
61};
62
63struct resources_ispif {
64 char *clock[CAMSS_RES_MAX];
65 char *clock_for_reset[CAMSS_RES_MAX];
66 char *reg[CAMSS_RES_MAX];
67 char *interrupt;
68};
69
70struct camss {
71 struct v4l2_device v4l2_dev;
72 struct v4l2_async_notifier notifier;
73 struct media_device media_dev;
74 struct device *dev;
75 struct csiphy_device csiphy[CAMSS_CSIPHY_NUM];
76 struct csid_device csid[CAMSS_CSID_NUM];
77 struct ispif_device ispif;
78 struct vfe_device vfe;
79 atomic_t ref_count;
80};
81
82struct camss_camera_interface {
83 u8 csiphy_id;
84 struct csiphy_csi2_cfg csi2;
85};
86
87struct camss_async_subdev {
88 struct camss_camera_interface interface;
89 struct v4l2_async_subdev asd;
90};
91
92struct camss_clock {
93 struct clk *clk;
94 const char *name;
95 u32 *freq;
96 u32 nfreqs;
97};
98
99void camss_add_clock_margin(u64 *rate);
100int camss_enable_clocks(int nclocks, struct camss_clock *clock,
101 struct device *dev);
102void camss_disable_clocks(int nclocks, struct camss_clock *clock);
103int camss_get_pixel_clock(struct media_entity *entity, u32 *pixel_clock);
104void camss_delete(struct camss *camss);
105
106#endif
107