• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * vin_core.h for video manage
3  *
4  * Copyright (c) 2017 by Allwinnertech Co., Ltd.  http://www.allwinnertech.com
5  *
6  * Authors:  Zhao Wei <zhaowei@allwinnertech.com>
7  *	Yang Feng <yangfeng@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 _VIN_CORE_H_
15 #define _VIN_CORE_H_
16 
17 #include <linux/types.h>
18 #include <linux/interrupt.h>
19 #include <linux/i2c.h>
20 #include <linux/workqueue.h>
21 #include <linux/pm_runtime.h>
22 
23 #include <media/sunxi_camera_v2.h>
24 #include <media/videobuf2-core.h>
25 #include <media/v4l2-device.h>
26 #include <media/v4l2-mediabus.h>
27 
28 #include "../platform/platform_cfg.h"
29 #include "../modules/flash/flash.h"
30 
31 #include "../modules/actuator/actuator.h"
32 #include "../vin-mipi/bsp_mipi_csi.h"
33 #include "../utility/vin_supply.h"
34 #include "vin_video.h"
35 #include "../vin.h"
36 
37 #define MAX_FRAME_MEM   (150*1024*1024)
38 #define MIN_WIDTH       (32)
39 #define MIN_HEIGHT      (32)
40 #define MAX_WIDTH       (4800)
41 #define MAX_HEIGHT      (4800)
42 
43 struct vin_status_info {
44 	unsigned int width;
45 	unsigned int height;
46 	unsigned int h_off;
47 	unsigned int v_off;
48 	unsigned int err_cnt;
49 	unsigned int buf_cnt;
50 	unsigned int buf_size;
51 	unsigned int buf_rest;
52 	unsigned int frame_cnt;
53 	unsigned int lost_cnt;
54 	unsigned int frame_internal;
55 	unsigned int max_internal;
56 	unsigned int min_internal;
57 	struct prs_input_para prs_in;
58 };
59 
60 struct vin_coor {
61 	unsigned int x1;
62 	unsigned int y1;
63 	unsigned int x2;
64 	unsigned int y2;
65 };
66 
67 struct vin_ptn_cfg {
68 	__u32 ptn_en;
69 	__u32 ptn_w;
70 	__u32 ptn_h;
71 	__u32 ptn_mode;
72 	__u32 ptn_dw;
73 	__u32 ptn_type;
74 	struct vin_mm ptn_buf;
75 };
76 
77 struct vin_core {
78 	unsigned char is_empty;
79 	unsigned char id;
80 	unsigned char support_raw;
81 	unsigned char total_rx_ch;
82 	unsigned char hflip;
83 	unsigned char vflip;
84 	unsigned char sensor_hflip;
85 	unsigned char sensor_vflip;
86 	unsigned char stream_idx;
87 	unsigned char fps_ds;
88 	unsigned char use_timer;
89 	unsigned char large_image;/*2:get merge yuv, 1: get pattern raw (save in kernel), 0: normal*/
90 	unsigned int rear_sensor;
91 	unsigned int front_sensor;
92 	unsigned int sensor_sel;
93 	unsigned int csi_sel;
94 	unsigned int mipi_sel;
95 	unsigned int isp_sel;
96 	unsigned int tdm_rx_sel;
97 	unsigned int vipp_sel;
98 	unsigned int isp_tx_ch;
99 	unsigned int vin_clk;
100 	unsigned int bandwidth;
101 	int irq;
102 	void __iomem *base;
103 	struct platform_device *pdev;
104 	struct isp_debug_mode isp_dbg;
105 	struct sensor_exp_gain exp_gain;
106 	struct v4l2_device *v4l2_dev;
107 	const struct vin_pipeline_ops *pipeline_ops;
108 	struct vin_status_info vin_status;
109 	struct timer_list timer_for_reset;
110 	struct vin_ptn_cfg ptn_cfg;
111 	struct vin_vid_cap vid_cap;
112 };
113 
get_valid_sensor(struct vin_core * vinc)114 static inline struct sensor_instance *get_valid_sensor(struct vin_core *vinc)
115 {
116 	struct vin_md *vind = dev_get_drvdata(vinc->v4l2_dev->dev);
117 	int valid_idx = NO_VALID_SENSOR;
118 
119 	valid_idx = vind->modules[vinc->sensor_sel].sensors.valid_idx;
120 
121 	if (valid_idx == NO_VALID_SENSOR)
122 		return NULL;
123 
124 	return &vind->modules[vinc->sensor_sel].sensors.inst[valid_idx];
125 }
126 int sunxi_vin_debug_register_driver(void);
127 void sunxi_vin_debug_unregister_driver(void);
128 int sunxi_vin_core_register_driver(void);
129 void sunxi_vin_core_unregister_driver(void);
130 struct vin_core *sunxi_vin_core_get_dev(int index);
131 struct vin_fmt *vin_find_format(const u32 *pixelformat, const u32 *mbus_code,
132 				  unsigned int mask, int index, bool have_code);
133 #endif /*_VIN_CORE_H_*/
134 
135