summaryrefslogtreecommitdiff
path: root/drivers/stream_input/tv_frontend/aml_fe.h (plain)
blob: f38c6466320bfef50396e5baef2c4c2eb3e365e2
1/*
2* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful, but WITHOUT
10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12* more details.
13*
14* You should have received a copy of the GNU General Public License along
15* with this program; if not, write to the Free Software Foundation, Inc.,
16* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*
18* Description:
19*/
20#ifndef _AML_FE_H_
21#define _AML_FE_H_
22
23
24#include <linux/interrupt.h>
25#include <linux/socket.h>
26#include <linux/netdevice.h>
27#include <linux/i2c.h>
28
29#include <linux/dvb/video.h>
30#include <linux/dvb/audio.h>
31#include <linux/dvb/dmx.h>
32#include <linux/dvb/ca.h>
33#include <linux/dvb/osd.h>
34#include <linux/dvb/net.h>
35#include <linux/mutex.h>
36#include <linux/spinlock.h>
37#include <linux/interrupt.h>
38
39#ifdef CONFIG_HAS_EARLYSUSPEND
40#include <linux/earlysuspend.h>
41#endif
42
43#include <dvbdev.h>
44#include <demux.h>
45#include <dvb_demux.h>
46#include <dmxdev.h>
47#include <dvb_filter.h>
48#include <dvb_net.h>
49#include <dvb_ringbuffer.h>
50#include <dvb_frontend.h>
51
52#include <linux/videodev2.h>
53#include <linux/amlogic/aml_gpio_consumer.h>
54
55#include <linux/of.h>
56#include <linux/of_fdt.h>
57#include <linux/pinctrl/consumer.h>
58#include <linux/amlogic/cpu_version.h>
59#include <linux/of_reserved_mem.h>
60
61#include "../parser/hw_demux/aml_dvb.h"
62
63enum aml_tuner_type_t {
64 AM_TUNER_NONE = 0,
65 AM_TUNER_SI2176 = 1,
66 AM_TUNER_SI2196 = 2,
67 AM_TUNER_FQ1216 = 3,
68 AM_TUNER_HTM = 4,
69 AM_TUNER_CTC703 = 5,
70 AM_TUNER_SI2177 = 6,
71 AM_TUNER_R840 = 7,
72 AM_TUNER_SI2157 = 8,
73 AM_TUNER_SI2151 = 9,
74 AM_TUNER_MXL661 = 10,
75 AM_TUNER_MXL608 = 11,
76 AM_TUNER_SI2159 = 12,
77 AM_TUNER_R842 = 13,
78 AM_TUNER_ATBM2040 = 14,
79};
80
81enum aml_atv_demod_type_t {
82 AM_ATV_DEMOD_SI2176 = 1,
83 AM_ATV_DEMOD_SI2196 = 2,
84 AM_ATV_DEMOD_FQ1216 = 3,
85 AM_ATV_DEMOD_HTM = 4,
86 AM_ATV_DEMOD_CTC703 = 5,
87 AM_ATV_DEMOD_SI2177 = 6,
88 AM_ATV_DEMOD_AML = 7,
89 AM_ATV_DEMOD_R840 = 8
90};
91
92enum aml_dtv_demod_type_t {
93 AM_DTV_DEMOD_M1 = 0,
94 AM_DTV_DEMOD_SI2176 = 1,
95 AM_DTV_DEMOD_MXL101 = 2,
96 AM_DTV_DEMOD_SI2196 = 3,
97 AM_DTV_DEMOD_AVL6211 = 4,
98 AM_DTV_DEMOD_SI2168 = 5,
99 AM_DTV_DEMOD_ITE9133 = 6,
100 AM_DTV_DEMOD_ITE9173 = 7,
101 AM_DTV_DEMOD_DIB8096 = 8,
102 AM_DTV_DEMOD_ATBM8869 = 9,
103 AM_DTV_DEMOD_MXL241 = 10,
104 AM_DTV_DEMOD_AVL68xx = 11,
105 AM_DTV_DEMOD_MXL683 = 12,
106 AM_DTV_DEMOD_ATBM8881 = 13
107};
108
109enum aml_fe_dev_type_t {
110 AM_DEV_TUNER,
111 AM_DEV_ATV_DEMOD,
112 AM_DEV_DTV_DEMOD
113};
114
115struct aml_fe_dev;
116struct aml_fe_man;
117struct aml_fe;
118
119struct aml_fe_drv {
120 struct module *owner;
121 struct aml_fe_drv *next;
122 enum aml_tuner_type_t id;
123 char *name;
124 int (*init)(struct aml_fe_dev *dev);
125 int (*release)(struct aml_fe_dev *dev);
126 int (*resume)(struct aml_fe_dev *dev);
127 int (*suspend)(struct aml_fe_dev *dev);
128 int (*support)(struct aml_fe_dev *dev, enum fe_delivery_system sys);
129 int (*get_ops)(struct aml_fe_dev *dev, enum fe_delivery_system sys,
130 struct dvb_frontend_ops *ops);
131 int (*init_sys)(struct aml_fe_dev *dev, enum fe_delivery_system sys);
132 int (*release_sys)(struct aml_fe_dev *dev, enum fe_delivery_system sys);
133 int (*start_blind_scan)(struct aml_fe_dev *dev);
134 int (*stop_blind_scan)(struct aml_fe_dev *dev);
135 int ref;
136};
137
138struct aml_fe_dev {
139 /*point to parent aml_fe */
140 enum aml_fe_dev_type_t type;
141 int dev_id;
142 struct aml_fe *fe;
143 struct aml_fe_man *man;
144 struct aml_fe_drv *drv;
145 void *priv_data;
146 /*i2c and reset gpio for all demod and tune*/
147 int i2c_adap_id;
148 int i2c_addr;
149 struct i2c_adapter *i2c_adap;
150 int reset_gpio;
151 int reset_value;
152};
153
154struct aml_fe {
155 struct dvb_frontend *fe;
156 struct aml_fe_man *man;
157#ifdef CONFIG_HAS_EARLYSUSPEND
158 struct early_suspend es;
159#endif /*CONFIG_HAS_EARLYSUSPEND */
160 spinlock_t slock;
161 int init;
162 int dev_id;
163 enum fe_delivery_system sys;
164 int sub_sys;
165/*used to identify T T2 OR C-A C-B C-C,S S2,ISDBT ISDBS ISDBC*/
166 enum aml_ts_source_t ts;
167 struct aml_fe_dev *tuner;
168 struct aml_fe_dev *atv_demod;
169 struct aml_fe_dev *dtv_demod;
170 struct workqueue_struct *work_q;
171 wait_queue_head_t wait_q;
172 struct work_struct work;
173 int work_running;
174 struct dvbsx_blindscanpara blind_scan_para;
175
176 /*Driver's work function.*/
177 void (*do_work)(struct aml_fe *fe);
178 /*Driver's property function.*/
179 int (*get_property)(struct dvb_frontend *fe, struct dtv_property *tvp);
180 int (*set_property)(struct dvb_frontend *fe, struct dtv_property *tvp);
181};
182
183struct aml_fe_man {
184 struct aml_dvb *dvb;
185 struct aml_fe fe[FE_DEV_COUNT];
186 struct aml_fe_dev tuner[FE_DEV_COUNT];
187 struct aml_fe_dev atv_demod[FE_DEV_COUNT];
188 struct aml_fe_dev dtv_demod[FE_DEV_COUNT];
189 struct dvb_frontend dev[FE_DEV_COUNT];
190 struct pinctrl *pinctrl;
191 struct platform_device *pdev;
192};
193
194extern int aml_register_fe_drv(enum aml_fe_dev_type_t type,
195 struct aml_fe_drv *drv);
196extern int aml_unregister_fe_drv(enum aml_fe_dev_type_t type,
197 struct aml_fe_drv *drv);
198
199extern int aml_fe_of_property_string(struct aml_fe_dev *dev,
200 const char *name, const char **str);
201extern int aml_fe_of_property_u32(struct aml_fe_dev *dev,
202 const char *name, u32 *v);
203
204extern void aml_fe_set_pdata(struct aml_fe_dev *dev, void *pdata);
205extern void *aml_fe_get_pdata(struct aml_fe_dev *dev);
206
207extern void aml_fe_schedule_work(struct aml_fe *fe,
208 void (*func)(struct aml_fe *fe));
209extern void aml_fe_cancel_work(struct aml_fe *fe);
210extern int aml_fe_work_cancelled(struct aml_fe *fe);
211extern int aml_fe_work_sleep(struct aml_fe *fe, unsigned long delay);
212
213#endif /*_AML_FE_H_*/
214