• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * linux-5.4/drivers/media/platform/sunxi-vin/vin-cci/cci_helper.h
3  *
4  * Copyright (c) 2007-2017 Allwinnertech Co., Ltd.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16 
17 /*
18  ******************************************************************************
19  *
20  * cci_helper.h
21  *
22  * Hawkview ISP - cci_helper.h module
23  *
24  * Copyright (c) 2014 by Allwinnertech Co., Ltd.  http://www.allwinnertech.com
25  *
26  * Version         Author         Date          Description
27  *
28  *   2.0         Yang Feng     2014/06/06      Second Version
29  *
30  ******************************************************************************
31  */
32 
33 #ifndef __VFE__I2C__H__
34 #define __VFE__I2C__H__
35 
36 #include <linux/i2c.h>
37 #include <media/v4l2-subdev.h>
38 #include <media/v4l2-device.h>
39 enum cci_dev_type {
40 	CCI_TYPE_SENSOR,
41 	CCI_TYPE_ACT,
42 	CCI_TYPE_FLASH,
43 };
44 
45 struct cci_driver {
46 	unsigned short id;
47 	char name[32];
48 	enum cci_dev_type type;
49 	struct device cci_device;
50 	struct device_attribute dev_attr_cci;
51 	unsigned short cci_id;
52 	unsigned short cci_saddr;
53 	struct v4l2_subdev *sd;
54 	unsigned int is_registerd;
55 	unsigned int is_matched;
56 
57 	int addr_width;
58 	int data_width;
59 	int read_flag;
60 	short read_value;
61 	struct mutex cci_mutex;
62 	struct list_head cci_list;
63 };
64 
65 struct reg_list_a8_d8 {
66 	unsigned char addr;
67 	unsigned char data;
68 };
69 
70 struct reg_list_a8_d16 {
71 	unsigned char addr;
72 	unsigned short data;
73 };
74 
75 struct reg_list_a16_d8 {
76 	unsigned short addr;
77 	unsigned char data;
78 };
79 
80 struct reg_list_a16_d16 {
81 	unsigned short addr;
82 	unsigned short data;
83 };
84 
85 struct reg_list_w_a16_d16 {
86 	unsigned short width;
87 	unsigned short addr;
88 	unsigned short data;
89 };
90 
91 typedef unsigned short addr_type;
92 typedef unsigned short data_type;
93 
94 extern void csi_cci_init_helper(unsigned int sel);
95 extern void csi_cci_exit_helper(unsigned int sel);
96 
97 extern int cci_read_a8_d8(struct v4l2_subdev *sd, unsigned char addr,
98 			  unsigned char *value);
99 extern int cci_write_a8_d8(struct v4l2_subdev *sd, unsigned char addr,
100 			   unsigned char value);
101 extern int cci_read_a8_d16(struct v4l2_subdev *sd, unsigned char addr,
102 			   unsigned short *value);
103 extern int cci_write_a8_d16(struct v4l2_subdev *sd, unsigned char addr,
104 			    unsigned short value);
105 extern int cci_read_a16_d8(struct v4l2_subdev *sd, unsigned short addr,
106 			   unsigned char *value);
107 extern int cci_write_a16_d8(struct v4l2_subdev *sd, unsigned short addr,
108 			    unsigned char value);
109 extern int cci_read_a16_d16(struct v4l2_subdev *sd, unsigned short addr,
110 			    unsigned short *value);
111 extern int cci_write_a16_d16(struct v4l2_subdev *sd, unsigned short addr,
112 			     unsigned short value);
113 extern int cci_write_a0_d16(struct v4l2_subdev *sd, unsigned short value);
114 extern int cci_write_a16_d8_continuous_helper(struct v4l2_subdev *sd,
115 					      unsigned short addr,
116 					      unsigned char *vals, uint size);
117 extern int cci_read(struct v4l2_subdev *sd, addr_type addr, data_type *value);
118 extern int cci_write(struct v4l2_subdev *sd, addr_type addr, data_type value);
119 
120 extern struct v4l2_subdev *cci_bus_match(char *name, unsigned short cci_id,
121 					 unsigned short cci_saddr);
122 extern void cci_bus_match_cancel(struct cci_driver *cci_drv_p);
123 
124 extern void cci_lock(struct v4l2_subdev *sd);
125 extern void cci_unlock(struct v4l2_subdev *sd);
126 
127 extern int cci_dev_init_helper(struct i2c_driver *sensor_driver);
128 extern void cci_dev_exit_helper(struct i2c_driver *sensor_driver);
129 extern int cci_dev_probe_helper(struct v4l2_subdev *sd,
130 				struct i2c_client *client,
131 				const struct v4l2_subdev_ops *sensor_ops,
132 				struct cci_driver *cci_drv);
133 extern struct v4l2_subdev *cci_dev_remove_helper(struct i2c_client *client,
134 						 struct cci_driver *cci_drv);
135 
136 #endif /*__VFE__I2C__H__*/
137