18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * FireDTV driver (formerly known as FireSAT) 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com> 68c2ecf20Sopenharmony_ci * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef _FIREDTV_H 108c2ecf20Sopenharmony_ci#define _FIREDTV_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/time.h> 138c2ecf20Sopenharmony_ci#include <linux/dvb/dmx.h> 148c2ecf20Sopenharmony_ci#include <linux/dvb/frontend.h> 158c2ecf20Sopenharmony_ci#include <linux/list.h> 168c2ecf20Sopenharmony_ci#include <linux/mod_devicetable.h> 178c2ecf20Sopenharmony_ci#include <linux/mutex.h> 188c2ecf20Sopenharmony_ci#include <linux/spinlock_types.h> 198c2ecf20Sopenharmony_ci#include <linux/types.h> 208c2ecf20Sopenharmony_ci#include <linux/wait.h> 218c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#include <media/demux.h> 248c2ecf20Sopenharmony_ci#include <media/dmxdev.h> 258c2ecf20Sopenharmony_ci#include <media/dvb_demux.h> 268c2ecf20Sopenharmony_ci#include <media/dvb_frontend.h> 278c2ecf20Sopenharmony_ci#include <media/dvb_net.h> 288c2ecf20Sopenharmony_ci#include <media/dvbdev.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistruct firedtv_tuner_status { 318c2ecf20Sopenharmony_ci unsigned active_system:8; 328c2ecf20Sopenharmony_ci unsigned searching:1; 338c2ecf20Sopenharmony_ci unsigned moving:1; 348c2ecf20Sopenharmony_ci unsigned no_rf:1; 358c2ecf20Sopenharmony_ci unsigned input:1; 368c2ecf20Sopenharmony_ci unsigned selected_antenna:7; 378c2ecf20Sopenharmony_ci unsigned ber:32; 388c2ecf20Sopenharmony_ci unsigned signal_strength:8; 398c2ecf20Sopenharmony_ci unsigned raster_frequency:2; 408c2ecf20Sopenharmony_ci unsigned rf_frequency:22; 418c2ecf20Sopenharmony_ci unsigned man_dep_info_length:8; 428c2ecf20Sopenharmony_ci unsigned front_end_error:1; 438c2ecf20Sopenharmony_ci unsigned antenna_error:1; 448c2ecf20Sopenharmony_ci unsigned front_end_power_status:1; 458c2ecf20Sopenharmony_ci unsigned power_supply:1; 468c2ecf20Sopenharmony_ci unsigned carrier_noise_ratio:16; 478c2ecf20Sopenharmony_ci unsigned power_supply_voltage:8; 488c2ecf20Sopenharmony_ci unsigned antenna_voltage:8; 498c2ecf20Sopenharmony_ci unsigned firewire_bus_voltage:8; 508c2ecf20Sopenharmony_ci unsigned ca_mmi:1; 518c2ecf20Sopenharmony_ci unsigned ca_pmt_reply:1; 528c2ecf20Sopenharmony_ci unsigned ca_date_time_request:1; 538c2ecf20Sopenharmony_ci unsigned ca_application_info:1; 548c2ecf20Sopenharmony_ci unsigned ca_module_present_status:1; 558c2ecf20Sopenharmony_ci unsigned ca_dvb_flag:1; 568c2ecf20Sopenharmony_ci unsigned ca_error_flag:1; 578c2ecf20Sopenharmony_ci unsigned ca_initialization_status:1; 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cienum model_type { 618c2ecf20Sopenharmony_ci FIREDTV_UNKNOWN = 0, 628c2ecf20Sopenharmony_ci FIREDTV_DVB_S = 1, 638c2ecf20Sopenharmony_ci FIREDTV_DVB_C = 2, 648c2ecf20Sopenharmony_ci FIREDTV_DVB_T = 3, 658c2ecf20Sopenharmony_ci FIREDTV_DVB_S2 = 4, 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistruct device; 698c2ecf20Sopenharmony_cistruct input_dev; 708c2ecf20Sopenharmony_cistruct fdtv_ir_context; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistruct firedtv { 738c2ecf20Sopenharmony_ci struct device *device; 748c2ecf20Sopenharmony_ci struct list_head list; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci struct dvb_adapter adapter; 778c2ecf20Sopenharmony_ci struct dmxdev dmxdev; 788c2ecf20Sopenharmony_ci struct dvb_demux demux; 798c2ecf20Sopenharmony_ci struct dmx_frontend frontend; 808c2ecf20Sopenharmony_ci struct dvb_net dvbnet; 818c2ecf20Sopenharmony_ci struct dvb_frontend fe; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci struct dvb_device *cadev; 848c2ecf20Sopenharmony_ci int ca_last_command; 858c2ecf20Sopenharmony_ci int ca_time_interval; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci struct mutex avc_mutex; 888c2ecf20Sopenharmony_ci wait_queue_head_t avc_wait; 898c2ecf20Sopenharmony_ci bool avc_reply_received; 908c2ecf20Sopenharmony_ci struct work_struct remote_ctrl_work; 918c2ecf20Sopenharmony_ci struct input_dev *remote_ctrl_dev; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci enum model_type type; 948c2ecf20Sopenharmony_ci char subunit; 958c2ecf20Sopenharmony_ci s8 isochannel; 968c2ecf20Sopenharmony_ci struct fdtv_ir_context *ir_context; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci enum fe_sec_voltage voltage; 998c2ecf20Sopenharmony_ci enum fe_sec_tone_mode tone; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci struct mutex demux_mutex; 1028c2ecf20Sopenharmony_ci unsigned long channel_active; 1038c2ecf20Sopenharmony_ci u16 channel_pid[16]; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci int avc_data_length; 1068c2ecf20Sopenharmony_ci u8 avc_data[512]; 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* firedtv-avc.c */ 1108c2ecf20Sopenharmony_ciint avc_recv(struct firedtv *fdtv, void *data, size_t length); 1118c2ecf20Sopenharmony_ciint avc_tuner_status(struct firedtv *fdtv, struct firedtv_tuner_status *stat); 1128c2ecf20Sopenharmony_cistruct dtv_frontend_properties; 1138c2ecf20Sopenharmony_ciint avc_tuner_dsd(struct firedtv *fdtv, struct dtv_frontend_properties *params); 1148c2ecf20Sopenharmony_ciint avc_tuner_set_pids(struct firedtv *fdtv, unsigned char pidc, u16 pid[]); 1158c2ecf20Sopenharmony_ciint avc_tuner_get_ts(struct firedtv *fdtv); 1168c2ecf20Sopenharmony_ciint avc_identify_subunit(struct firedtv *fdtv); 1178c2ecf20Sopenharmony_cistruct dvb_diseqc_master_cmd; 1188c2ecf20Sopenharmony_ciint avc_lnb_control(struct firedtv *fdtv, char voltage, char burst, 1198c2ecf20Sopenharmony_ci char conttone, char nrdiseq, 1208c2ecf20Sopenharmony_ci struct dvb_diseqc_master_cmd *diseqcmd); 1218c2ecf20Sopenharmony_civoid avc_remote_ctrl_work(struct work_struct *work); 1228c2ecf20Sopenharmony_ciint avc_register_remote_control(struct firedtv *fdtv); 1238c2ecf20Sopenharmony_ciint avc_ca_app_info(struct firedtv *fdtv, unsigned char *app_info, 1248c2ecf20Sopenharmony_ci unsigned int *len); 1258c2ecf20Sopenharmony_ciint avc_ca_info(struct firedtv *fdtv, unsigned char *app_info, 1268c2ecf20Sopenharmony_ci unsigned int *len); 1278c2ecf20Sopenharmony_ciint avc_ca_reset(struct firedtv *fdtv); 1288c2ecf20Sopenharmony_ciint avc_ca_pmt(struct firedtv *fdtv, char *app_info, int length); 1298c2ecf20Sopenharmony_ciint avc_ca_get_time_date(struct firedtv *fdtv, int *interval); 1308c2ecf20Sopenharmony_ciint avc_ca_enter_menu(struct firedtv *fdtv); 1318c2ecf20Sopenharmony_ciint avc_ca_get_mmi(struct firedtv *fdtv, char *mmi_object, unsigned int *len); 1328c2ecf20Sopenharmony_ciint cmp_establish_pp_connection(struct firedtv *fdtv, int plug, int channel); 1338c2ecf20Sopenharmony_civoid cmp_break_pp_connection(struct firedtv *fdtv, int plug, int channel); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci/* firedtv-ci.c */ 1368c2ecf20Sopenharmony_ciint fdtv_ca_register(struct firedtv *fdtv); 1378c2ecf20Sopenharmony_civoid fdtv_ca_release(struct firedtv *fdtv); 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci/* firedtv-dvb.c */ 1408c2ecf20Sopenharmony_ciint fdtv_start_feed(struct dvb_demux_feed *dvbdmxfeed); 1418c2ecf20Sopenharmony_ciint fdtv_stop_feed(struct dvb_demux_feed *dvbdmxfeed); 1428c2ecf20Sopenharmony_ciint fdtv_dvb_register(struct firedtv *fdtv, const char *name); 1438c2ecf20Sopenharmony_civoid fdtv_dvb_unregister(struct firedtv *fdtv); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci/* firedtv-fe.c */ 1468c2ecf20Sopenharmony_civoid fdtv_frontend_init(struct firedtv *fdtv, const char *name); 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci/* firedtv-fw.c */ 1498c2ecf20Sopenharmony_ciint fdtv_lock(struct firedtv *fdtv, u64 addr, void *data); 1508c2ecf20Sopenharmony_ciint fdtv_read(struct firedtv *fdtv, u64 addr, void *data); 1518c2ecf20Sopenharmony_ciint fdtv_write(struct firedtv *fdtv, u64 addr, void *data, size_t len); 1528c2ecf20Sopenharmony_ciint fdtv_start_iso(struct firedtv *fdtv); 1538c2ecf20Sopenharmony_civoid fdtv_stop_iso(struct firedtv *fdtv); 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci/* firedtv-rc.c */ 1568c2ecf20Sopenharmony_ci#ifdef CONFIG_DVB_FIREDTV_INPUT 1578c2ecf20Sopenharmony_ciint fdtv_register_rc(struct firedtv *fdtv, struct device *dev); 1588c2ecf20Sopenharmony_civoid fdtv_unregister_rc(struct firedtv *fdtv); 1598c2ecf20Sopenharmony_civoid fdtv_handle_rc(struct firedtv *fdtv, unsigned int code); 1608c2ecf20Sopenharmony_ci#else 1618c2ecf20Sopenharmony_cistatic inline int fdtv_register_rc(struct firedtv *fdtv, 1628c2ecf20Sopenharmony_ci struct device *dev) { return 0; } 1638c2ecf20Sopenharmony_cistatic inline void fdtv_unregister_rc(struct firedtv *fdtv) {} 1648c2ecf20Sopenharmony_cistatic inline void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code) {} 1658c2ecf20Sopenharmony_ci#endif 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci#endif /* _FIREDTV_H */ 168