init scaler core
[firefly-linux-kernel-4.4.55.git] / drivers / misc / scaler / scaler-core.h
1 #ifndef __SCALER_CORE_H__
2 #define __SCALER_CORE_H__
3 #include <linux/platform_device.h>
4 #include <linux/i2c.h>
5 #include <linux/cdev.h>
6 #include <linux/file.h>
7 #include <linux/list.h>
8
9
10 struct display_edid {
11         char *data;
12         char *ext_data;
13 };
14
15 enum scaler_output_type {
16         SCALER_OUT_INVALID = 0,
17         SCALER_OUT_LVDS,
18         SCALER_OUT_VGA,
19         SCALER_OUT_RGB,
20         SCALER_OUT_HDMI,
21         SCALER_OUT_DP,
22         SCALER_OUT_NUMS,
23 };
24
25 enum scaler_input_type {
26         SCALER_IN_INVALID = 0,
27         SCALER_IN_VGA,
28         SCALER_IN_RGB,
29         SCALER_IN_DVI,
30         SCALER_IN_YPBPR,
31         SCALER_IN_YCBCR,
32         SCALER_IN_DP,
33         SCALER_IN_HDMI,
34         SCALER_IN_MYDP,
35         SCALER_IN_IDP,
36         SCALER_IN_NUMS,
37 };
38
39 enum scaler_bus_type {
40         SCALER_BUS_TYPE_INVALID = 0,
41         SCALER_BUS_TYPE_UART,
42         SCALER_BUS_TYPE_I2C,
43         SCALER_BUS_TYPE_SPI,
44         SCALER_BUS_TYPE_NUMS,
45 };
46
47 /*
48  * the function of scaler, for example convertor or switch 
49 */
50 enum scaler_function_type {
51         SCALER_FUNC_INVALID = 0,
52         SCALER_FUNC_CONVERTOR,   //转换器
53         SCALER_FUNC_SWITCH,      //切换开关多选一输出 
54         SCALER_FUNC_FULL,        //全功能
55         SCALER_FUNC_NUMS,
56 };
57
58 struct scaler_output_port {
59         int id;
60         int max_hres;
61         int max_vres;
62         int freq;
63         unsigned led_gpio;   //working led
64         enum scaler_output_type type;
65         struct list_head next; 
66 };
67
68 struct scaler_input_port {
69         int id;
70         int max_hres;
71         int max_vres;
72         int freq;       //HZ
73         unsigned led_gpio;   //working led
74         enum scaler_input_type type;
75         struct list_head next; 
76 };
77
78 struct scaler_chip_dev {
79         char id;
80         char name[I2C_NAME_SIZE];
81         struct i2c_client *client;
82         
83         enum scaler_function_type func_type;
84
85         int int_gpio;
86         int reset_gpio;
87         int power_gpio;
88         int status_gpio;
89         int reg_size;  //8bit = 1, 16bit = 2, 24bit = 3,32bit = 4.
90
91         struct list_head oports; //config all support output type by make menuconfig
92         struct list_head iports; //config all support input type by make menuconfig
93         enum scaler_input_type cur_in_type;
94         enum scaler_output_type cur_out_type;
95
96         //init hardware(gpio etc.)
97         int (*init_hw)(void);
98         int (*exit_hw)(void);
99
100         //enable chip to process image
101         void (*start)(void);
102         //disable chip to process image
103         void (*stop)(void);
104         void (*reset)(char active);
105         void (*suspend)(void);
106         void (*resume)(void);
107
108         //
109         int (*read)(unsigned short reg, int bytes, void *dest);
110         int (*write)(unsigned short reg, int bytes, void *src);
111         int (*parse_cmd)(unsigned int cmd, void *arg);
112         int (*update_firmware)(void *data);
113
114         //scaler chip dev list
115         struct list_head next;
116 };
117
118 struct scaler_platform_data {
119         int int_gpio;
120         int reset_gpio;
121         int power_gpio;
122         int status_gpio; //check chip if work on lower power mode or normal mode.
123         //config input indicator lamp
124         unsigned in_leds_gpio[SCALER_IN_NUMS];  
125         //config output indicator lamp
126         unsigned out_leds_gpio[SCALER_OUT_NUMS];  
127
128         char *firmware; 
129         //function type
130         enum scaler_function_type func_type;
131
132         //config in and out 
133         enum scaler_input_type *iports;
134         enum scaler_output_type *oports;
135         int iport_size;
136         int oport_size;
137         enum scaler_input_type default_in;
138         enum scaler_output_type default_out;
139
140         int (*init_hw)(void);
141         int (*exit_hw)(void);
142 };
143
144 struct scaler_device {
145         struct class *class;
146         dev_t devno;
147         struct cdev *cdev;
148
149         struct display_edid edid;
150
151         struct list_head chips;
152 };
153
154 struct scaler_chip_dev *alloc_scaler_chip(void);
155 //free chip memory and port memory
156 void free_scaler_chip(struct scaler_chip_dev *chip);
157 int init_scaler_chip(struct scaler_chip_dev *chip, struct scaler_platform_data *pdata);
158 //
159 int register_scaler_chip(struct scaler_chip_dev *chip);
160 int unregister_scaler_chip(struct scaler_chip_dev *chip);
161
162 #define SCALER_IOCTL_MAGIC 's'
163 #define SCALER_IOCTL_POWER _IOW(SCALER_IOCTL_MAGIC, 0x00, char)
164 #define SCALER_IOCTL_GET_CUR_INPUT _IOR(SCALER_IOCTL_MAGIC, 0x01, int port_id)
165 #define SCALER_IOCTL_SET_CUR_INPUT _IOW(SCALER_IOCTL_MAGIC, 0x02, int port_id)
166
167 #endif