GNU Linux-libre 4.14.251-gnu1
[releases.git] / drivers / media / platform / qcom / camss-8x16 / camss-csid.h
1 /*
2  * camss-csid.h
3  *
4  * Qualcomm MSM Camera Subsystem - CSID (CSI Decoder) Module
5  *
6  * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
7  * Copyright (C) 2015-2017 Linaro Ltd.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 and
11  * only version 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  */
18 #ifndef QC_MSM_CAMSS_CSID_H
19 #define QC_MSM_CAMSS_CSID_H
20
21 #include <linux/clk.h>
22 #include <media/media-entity.h>
23 #include <media/v4l2-ctrls.h>
24 #include <media/v4l2-device.h>
25 #include <media/v4l2-mediabus.h>
26 #include <media/v4l2-subdev.h>
27
28 #define MSM_CSID_PAD_SINK 0
29 #define MSM_CSID_PAD_SRC 1
30 #define MSM_CSID_PADS_NUM 2
31
32 enum csid_payload_mode {
33         CSID_PAYLOAD_MODE_INCREMENTING = 0,
34         CSID_PAYLOAD_MODE_ALTERNATING_55_AA = 1,
35         CSID_PAYLOAD_MODE_ALL_ZEROES = 2,
36         CSID_PAYLOAD_MODE_ALL_ONES = 3,
37         CSID_PAYLOAD_MODE_RANDOM = 4,
38         CSID_PAYLOAD_MODE_USER_SPECIFIED = 5,
39 };
40
41 struct csid_testgen_config {
42         u8 enabled;
43         enum csid_payload_mode payload_mode;
44 };
45
46 struct csid_phy_config {
47         u8 csiphy_id;
48         u8 lane_cnt;
49         u32 lane_assign;
50 };
51
52 struct csid_device {
53         u8 id;
54         struct v4l2_subdev subdev;
55         struct media_pad pads[MSM_CSID_PADS_NUM];
56         void __iomem *base;
57         u32 irq;
58         char irq_name[30];
59         struct camss_clock *clock;
60         int nclocks;
61         struct regulator *vdda;
62         struct completion reset_complete;
63         struct csid_testgen_config testgen;
64         struct csid_phy_config phy;
65         struct v4l2_mbus_framefmt fmt[MSM_CSID_PADS_NUM];
66         struct v4l2_ctrl_handler ctrls;
67         struct v4l2_ctrl *testgen_mode;
68 };
69
70 struct resources;
71
72 int msm_csid_subdev_init(struct csid_device *csid,
73                          const struct resources *res, u8 id);
74
75 int msm_csid_register_entity(struct csid_device *csid,
76                              struct v4l2_device *v4l2_dev);
77
78 void msm_csid_unregister_entity(struct csid_device *csid);
79
80 void msm_csid_get_csid_id(struct media_entity *entity, u8 *id);
81
82 #endif /* QC_MSM_CAMSS_CSID_H */