• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * sensor_helper.h: helper function for sensors.
4  *
5  * Copyright (c) 2017 by Allwinnertech Co., Ltd.  http://www.allwinnertech.com
6  *
7  * Authors:  Zhao Wei <zhaowei@allwinnertech.com>
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 as
11  * published by the Free Software Foundation.
12  */
13 
14 #ifndef __SENSOR__HELPER__H__
15 #define __SENSOR__HELPER__H__
16 
17 #include <media/v4l2-subdev.h>
18 #include <linux/videodev2.h>
19 #include "../../vin-video/vin_core.h"
20 #include "../../utility/vin_supply.h"
21 #include "../../vin-cci/cci_helper.h"
22 #include "camera_cfg.h"
23 #include "camera.h"
24 #include "../flash/flash.h"
25 #include "../../platform/platform_cfg.h"
26 
27 #define REG_DLY  0xffff
28 
29 struct regval_list {
30 	addr_type addr;
31 	data_type data;
32 };
33 
34 struct sensor_helper_dev {
35 	struct regulator *pmic[MAX_POW_NUM];
36 	char name[I2C_NAME_SIZE];
37 	unsigned int id;
38 };
39 
40 #define DEV_DBG_EN   0
41 #if (DEV_DBG_EN == 1)
42 #define sensor_dbg(x, arg...) printk(KERN_DEBUG "[%s]"x, SENSOR_NAME, ##arg)
43 #else
44 #define sensor_dbg(x, arg...)
45 #endif
46 
47 #define sensor_err(x, arg...) pr_err("[%s] error, "x, SENSOR_NAME, ##arg)
48 #define sensor_print(x, arg...) pr_info("[%s]"x, SENSOR_NAME, ##arg)
49 
50 extern int sensor_read(struct v4l2_subdev *sd, addr_type addr,
51 		       data_type *value);
52 extern int sensor_write(struct v4l2_subdev *sd, addr_type addr,
53 			data_type value);
54 extern int sensor_write_array(struct v4l2_subdev *sd,
55 				struct regval_list *regs,
56 				int array_size);
57 #ifdef CONFIG_COMPAT
58 extern long sensor_compat_ioctl32(struct v4l2_subdev *sd,
59 		unsigned int cmd, unsigned long arg);
60 #endif
61 extern struct sensor_info *to_state(struct v4l2_subdev *sd);
62 extern void sensor_cfg_req(struct v4l2_subdev *sd, struct sensor_config *cfg);
63 extern void sensor_isp_input(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf);
64 extern unsigned int sensor_get_exp(struct v4l2_subdev *sd);
65 extern unsigned int sensor_get_clk(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg,
66 			unsigned long *top_clk, unsigned long *isp_clk);
67 extern int sensor_enum_mbus_code(struct v4l2_subdev *sd,
68 				struct v4l2_subdev_pad_config *cfg,
69 				struct v4l2_subdev_mbus_code_enum *code);
70 extern int sensor_enum_frame_size(struct v4l2_subdev *sd,
71 			struct v4l2_subdev_pad_config *cfg,
72 			struct v4l2_subdev_frame_size_enum *fse);
73 extern int sensor_get_fmt(struct v4l2_subdev *sd,
74 			struct v4l2_subdev_pad_config *cfg,
75 			struct v4l2_subdev_format *fmt);
76 extern int sensor_set_fmt(struct v4l2_subdev *sd,
77 			struct v4l2_subdev_pad_config *cfg,
78 			struct v4l2_subdev_format *fmt);
79 extern int sensor_g_parm(struct v4l2_subdev *sd,
80 			struct v4l2_streamparm *parms);
81 extern int sensor_s_parm(struct v4l2_subdev *sd,
82 			struct v4l2_streamparm *parms);
83 extern int sensor_try_ctrl(struct v4l2_ctrl *ctrl);
84 
85 extern int actuator_init(struct v4l2_subdev *sd, struct actuator_para *range);
86 extern int actuator_set_code(struct v4l2_subdev *sd, struct actuator_ctrl *pos);
87 extern int flash_en(struct v4l2_subdev *sd, struct flash_para *para);
88 
89 #endif
90