xref: /openbmc/linux/drivers/media/firewire/firedtv.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*2874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2616300bdSMauro Carvalho Chehab /*
3616300bdSMauro Carvalho Chehab  * FireDTV driver (formerly known as FireSAT)
4616300bdSMauro Carvalho Chehab  *
5616300bdSMauro Carvalho Chehab  * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
6616300bdSMauro Carvalho Chehab  * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se>
7616300bdSMauro Carvalho Chehab  */
8616300bdSMauro Carvalho Chehab 
9616300bdSMauro Carvalho Chehab #ifndef _FIREDTV_H
10616300bdSMauro Carvalho Chehab #define _FIREDTV_H
11616300bdSMauro Carvalho Chehab 
12b2409b65SMauro Carvalho Chehab #include <linux/time.h>
13616300bdSMauro Carvalho Chehab #include <linux/dvb/dmx.h>
14616300bdSMauro Carvalho Chehab #include <linux/dvb/frontend.h>
15616300bdSMauro Carvalho Chehab #include <linux/list.h>
16616300bdSMauro Carvalho Chehab #include <linux/mod_devicetable.h>
17616300bdSMauro Carvalho Chehab #include <linux/mutex.h>
18616300bdSMauro Carvalho Chehab #include <linux/spinlock_types.h>
19616300bdSMauro Carvalho Chehab #include <linux/types.h>
20616300bdSMauro Carvalho Chehab #include <linux/wait.h>
21616300bdSMauro Carvalho Chehab #include <linux/workqueue.h>
22616300bdSMauro Carvalho Chehab 
23fada1935SMauro Carvalho Chehab #include <media/demux.h>
24fada1935SMauro Carvalho Chehab #include <media/dmxdev.h>
25fada1935SMauro Carvalho Chehab #include <media/dvb_demux.h>
26fada1935SMauro Carvalho Chehab #include <media/dvb_frontend.h>
27fada1935SMauro Carvalho Chehab #include <media/dvb_net.h>
28fada1935SMauro Carvalho Chehab #include <media/dvbdev.h>
29616300bdSMauro Carvalho Chehab 
30616300bdSMauro Carvalho Chehab struct firedtv_tuner_status {
31616300bdSMauro Carvalho Chehab 	unsigned active_system:8;
32616300bdSMauro Carvalho Chehab 	unsigned searching:1;
33616300bdSMauro Carvalho Chehab 	unsigned moving:1;
34616300bdSMauro Carvalho Chehab 	unsigned no_rf:1;
35616300bdSMauro Carvalho Chehab 	unsigned input:1;
36616300bdSMauro Carvalho Chehab 	unsigned selected_antenna:7;
37616300bdSMauro Carvalho Chehab 	unsigned ber:32;
38616300bdSMauro Carvalho Chehab 	unsigned signal_strength:8;
39616300bdSMauro Carvalho Chehab 	unsigned raster_frequency:2;
40616300bdSMauro Carvalho Chehab 	unsigned rf_frequency:22;
41616300bdSMauro Carvalho Chehab 	unsigned man_dep_info_length:8;
42616300bdSMauro Carvalho Chehab 	unsigned front_end_error:1;
43616300bdSMauro Carvalho Chehab 	unsigned antenna_error:1;
44616300bdSMauro Carvalho Chehab 	unsigned front_end_power_status:1;
45616300bdSMauro Carvalho Chehab 	unsigned power_supply:1;
46616300bdSMauro Carvalho Chehab 	unsigned carrier_noise_ratio:16;
47616300bdSMauro Carvalho Chehab 	unsigned power_supply_voltage:8;
48616300bdSMauro Carvalho Chehab 	unsigned antenna_voltage:8;
49616300bdSMauro Carvalho Chehab 	unsigned firewire_bus_voltage:8;
50616300bdSMauro Carvalho Chehab 	unsigned ca_mmi:1;
51616300bdSMauro Carvalho Chehab 	unsigned ca_pmt_reply:1;
52616300bdSMauro Carvalho Chehab 	unsigned ca_date_time_request:1;
53616300bdSMauro Carvalho Chehab 	unsigned ca_application_info:1;
54616300bdSMauro Carvalho Chehab 	unsigned ca_module_present_status:1;
55616300bdSMauro Carvalho Chehab 	unsigned ca_dvb_flag:1;
56616300bdSMauro Carvalho Chehab 	unsigned ca_error_flag:1;
57616300bdSMauro Carvalho Chehab 	unsigned ca_initialization_status:1;
58616300bdSMauro Carvalho Chehab };
59616300bdSMauro Carvalho Chehab 
60616300bdSMauro Carvalho Chehab enum model_type {
61616300bdSMauro Carvalho Chehab 	FIREDTV_UNKNOWN = 0,
62616300bdSMauro Carvalho Chehab 	FIREDTV_DVB_S   = 1,
63616300bdSMauro Carvalho Chehab 	FIREDTV_DVB_C   = 2,
64616300bdSMauro Carvalho Chehab 	FIREDTV_DVB_T   = 3,
65616300bdSMauro Carvalho Chehab 	FIREDTV_DVB_S2  = 4,
66616300bdSMauro Carvalho Chehab };
67616300bdSMauro Carvalho Chehab 
68616300bdSMauro Carvalho Chehab struct device;
69616300bdSMauro Carvalho Chehab struct input_dev;
70616300bdSMauro Carvalho Chehab struct fdtv_ir_context;
71616300bdSMauro Carvalho Chehab 
72616300bdSMauro Carvalho Chehab struct firedtv {
73616300bdSMauro Carvalho Chehab 	struct device *device;
74616300bdSMauro Carvalho Chehab 	struct list_head list;
75616300bdSMauro Carvalho Chehab 
76616300bdSMauro Carvalho Chehab 	struct dvb_adapter	adapter;
77616300bdSMauro Carvalho Chehab 	struct dmxdev		dmxdev;
78616300bdSMauro Carvalho Chehab 	struct dvb_demux	demux;
79616300bdSMauro Carvalho Chehab 	struct dmx_frontend	frontend;
80616300bdSMauro Carvalho Chehab 	struct dvb_net		dvbnet;
81616300bdSMauro Carvalho Chehab 	struct dvb_frontend	fe;
82616300bdSMauro Carvalho Chehab 
83616300bdSMauro Carvalho Chehab 	struct dvb_device	*cadev;
84616300bdSMauro Carvalho Chehab 	int			ca_last_command;
85616300bdSMauro Carvalho Chehab 	int			ca_time_interval;
86616300bdSMauro Carvalho Chehab 
87616300bdSMauro Carvalho Chehab 	struct mutex		avc_mutex;
88616300bdSMauro Carvalho Chehab 	wait_queue_head_t	avc_wait;
89616300bdSMauro Carvalho Chehab 	bool			avc_reply_received;
90616300bdSMauro Carvalho Chehab 	struct work_struct	remote_ctrl_work;
91616300bdSMauro Carvalho Chehab 	struct input_dev	*remote_ctrl_dev;
92616300bdSMauro Carvalho Chehab 
93616300bdSMauro Carvalho Chehab 	enum model_type		type;
94616300bdSMauro Carvalho Chehab 	char			subunit;
95f2dd851fSMauro Carvalho Chehab 	s8			isochannel;
96616300bdSMauro Carvalho Chehab 	struct fdtv_ir_context	*ir_context;
97616300bdSMauro Carvalho Chehab 
980df289a2SMauro Carvalho Chehab 	enum fe_sec_voltage	voltage;
990df289a2SMauro Carvalho Chehab 	enum fe_sec_tone_mode	tone;
100616300bdSMauro Carvalho Chehab 
101616300bdSMauro Carvalho Chehab 	struct mutex		demux_mutex;
102616300bdSMauro Carvalho Chehab 	unsigned long		channel_active;
103616300bdSMauro Carvalho Chehab 	u16			channel_pid[16];
104616300bdSMauro Carvalho Chehab 
105616300bdSMauro Carvalho Chehab 	int			avc_data_length;
106616300bdSMauro Carvalho Chehab 	u8			avc_data[512];
107616300bdSMauro Carvalho Chehab };
108616300bdSMauro Carvalho Chehab 
109616300bdSMauro Carvalho Chehab /* firedtv-avc.c */
110616300bdSMauro Carvalho Chehab int avc_recv(struct firedtv *fdtv, void *data, size_t length);
111616300bdSMauro Carvalho Chehab int avc_tuner_status(struct firedtv *fdtv, struct firedtv_tuner_status *stat);
112616300bdSMauro Carvalho Chehab struct dtv_frontend_properties;
113616300bdSMauro Carvalho Chehab int avc_tuner_dsd(struct firedtv *fdtv, struct dtv_frontend_properties *params);
114616300bdSMauro Carvalho Chehab int avc_tuner_set_pids(struct firedtv *fdtv, unsigned char pidc, u16 pid[]);
115616300bdSMauro Carvalho Chehab int avc_tuner_get_ts(struct firedtv *fdtv);
116616300bdSMauro Carvalho Chehab int avc_identify_subunit(struct firedtv *fdtv);
117616300bdSMauro Carvalho Chehab struct dvb_diseqc_master_cmd;
118616300bdSMauro Carvalho Chehab int avc_lnb_control(struct firedtv *fdtv, char voltage, char burst,
119616300bdSMauro Carvalho Chehab 		    char conttone, char nrdiseq,
120616300bdSMauro Carvalho Chehab 		    struct dvb_diseqc_master_cmd *diseqcmd);
121616300bdSMauro Carvalho Chehab void avc_remote_ctrl_work(struct work_struct *work);
122616300bdSMauro Carvalho Chehab int avc_register_remote_control(struct firedtv *fdtv);
123b2e9a4edSNathan Chancellor int avc_ca_app_info(struct firedtv *fdtv, unsigned char *app_info,
124b2e9a4edSNathan Chancellor 		    unsigned int *len);
125b2e9a4edSNathan Chancellor int avc_ca_info(struct firedtv *fdtv, unsigned char *app_info,
126b2e9a4edSNathan Chancellor 		unsigned int *len);
127616300bdSMauro Carvalho Chehab int avc_ca_reset(struct firedtv *fdtv);
128616300bdSMauro Carvalho Chehab int avc_ca_pmt(struct firedtv *fdtv, char *app_info, int length);
129616300bdSMauro Carvalho Chehab int avc_ca_get_time_date(struct firedtv *fdtv, int *interval);
130616300bdSMauro Carvalho Chehab int avc_ca_enter_menu(struct firedtv *fdtv);
131616300bdSMauro Carvalho Chehab int avc_ca_get_mmi(struct firedtv *fdtv, char *mmi_object, unsigned int *len);
132616300bdSMauro Carvalho Chehab int cmp_establish_pp_connection(struct firedtv *fdtv, int plug, int channel);
133616300bdSMauro Carvalho Chehab void cmp_break_pp_connection(struct firedtv *fdtv, int plug, int channel);
134616300bdSMauro Carvalho Chehab 
135616300bdSMauro Carvalho Chehab /* firedtv-ci.c */
136616300bdSMauro Carvalho Chehab int fdtv_ca_register(struct firedtv *fdtv);
137616300bdSMauro Carvalho Chehab void fdtv_ca_release(struct firedtv *fdtv);
138616300bdSMauro Carvalho Chehab 
139616300bdSMauro Carvalho Chehab /* firedtv-dvb.c */
140616300bdSMauro Carvalho Chehab int fdtv_start_feed(struct dvb_demux_feed *dvbdmxfeed);
141616300bdSMauro Carvalho Chehab int fdtv_stop_feed(struct dvb_demux_feed *dvbdmxfeed);
142616300bdSMauro Carvalho Chehab int fdtv_dvb_register(struct firedtv *fdtv, const char *name);
143616300bdSMauro Carvalho Chehab void fdtv_dvb_unregister(struct firedtv *fdtv);
144616300bdSMauro Carvalho Chehab 
145616300bdSMauro Carvalho Chehab /* firedtv-fe.c */
146616300bdSMauro Carvalho Chehab void fdtv_frontend_init(struct firedtv *fdtv, const char *name);
147616300bdSMauro Carvalho Chehab 
148616300bdSMauro Carvalho Chehab /* firedtv-fw.c */
149616300bdSMauro Carvalho Chehab int fdtv_lock(struct firedtv *fdtv, u64 addr, void *data);
150616300bdSMauro Carvalho Chehab int fdtv_read(struct firedtv *fdtv, u64 addr, void *data);
151616300bdSMauro Carvalho Chehab int fdtv_write(struct firedtv *fdtv, u64 addr, void *data, size_t len);
152616300bdSMauro Carvalho Chehab int fdtv_start_iso(struct firedtv *fdtv);
153616300bdSMauro Carvalho Chehab void fdtv_stop_iso(struct firedtv *fdtv);
154616300bdSMauro Carvalho Chehab 
155616300bdSMauro Carvalho Chehab /* firedtv-rc.c */
156616300bdSMauro Carvalho Chehab #ifdef CONFIG_DVB_FIREDTV_INPUT
157616300bdSMauro Carvalho Chehab int fdtv_register_rc(struct firedtv *fdtv, struct device *dev);
158616300bdSMauro Carvalho Chehab void fdtv_unregister_rc(struct firedtv *fdtv);
159616300bdSMauro Carvalho Chehab void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code);
160616300bdSMauro Carvalho Chehab #else
fdtv_register_rc(struct firedtv * fdtv,struct device * dev)161616300bdSMauro Carvalho Chehab static inline int fdtv_register_rc(struct firedtv *fdtv,
162616300bdSMauro Carvalho Chehab 				   struct device *dev) { return 0; }
fdtv_unregister_rc(struct firedtv * fdtv)163616300bdSMauro Carvalho Chehab static inline void fdtv_unregister_rc(struct firedtv *fdtv) {}
fdtv_handle_rc(struct firedtv * fdtv,unsigned int code)164616300bdSMauro Carvalho Chehab static inline void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code) {}
165616300bdSMauro Carvalho Chehab #endif
166616300bdSMauro Carvalho Chehab 
167616300bdSMauro Carvalho Chehab #endif /* _FIREDTV_H */
168