diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 85c5f2bcd5fc..6f95738de555 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -1120,7 +1120,11 @@ static int dvb_frontend_clear_cache(struct dvb_frontend *fe) #define _DTV_CMD(n) \ [n] = #n +#ifdef CONFIG_AMLOGIC_DVB_COMPAT +static char *dtv_cmds[AML_DTV_MAX_COMMAND + 1] = { +#else static char *dtv_cmds[DTV_MAX_COMMAND + 1] = { +#endif _DTV_CMD(DTV_TUNE), _DTV_CMD(DTV_CLEAR), @@ -1216,7 +1220,11 @@ static char *dtv_cmds[DTV_MAX_COMMAND + 1] = { static char *dtv_cmd_name(u32 cmd) { +#ifdef CONFIG_AMLOGIC_DVB_COMPAT + cmd = array_index_nospec(cmd, AML_DTV_MAX_COMMAND); +#else cmd = array_index_nospec(cmd, DTV_MAX_COMMAND); +#endif return dtv_cmds[cmd]; } @@ -1984,7 +1992,11 @@ static int dtv_property_process_set(struct dvb_frontend *fe, #endif /** Dump DTV command name and value*/ +#ifdef CONFIG_AMLOGIC_DVB_COMPAT + if (!cmd || cmd > AML_DTV_MAX_COMMAND) +#else if (!cmd || cmd > DTV_MAX_COMMAND) +#endif dev_warn(fe->dvb->device, "%s: SET cmd 0x%08x undefined\n", __func__, cmd); else diff --git a/include/media/dvb_frontend.h b/include/media/dvb_frontend.h index 0e551c31edd4..8ea3c543874f 100644 --- a/include/media/dvb_frontend.h +++ b/include/media/dvb_frontend.h @@ -43,7 +43,9 @@ #include #include -#include +#ifdef CONFIG_AMLOGIC_DVB_COMPAT +#include +#endif #include diff --git a/include/uapi/linux/dvb/aml_fe_ext.h b/include/uapi/linux/dvb/aml_fe_ext.h new file mode 100644 index 000000000000..98eb8efa6716 --- /dev/null +++ b/include/uapi/linux/dvb/aml_fe_ext.h @@ -0,0 +1,211 @@ +/* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */ +/* + * Copyright (c) 2019 Amlogic, Inc. All rights reserved. + */ + +#ifndef _AML_FE_EXT_H_ +#define _AML_FE_EXT_H_ + +#include + +#include + +#ifdef __KERNEL__ +#include +#else +#include "frontend.h" +#endif + +#define FE_ANALOG (FE_ATSC + 1) +#define FE_DTMB (FE_ANALOG + 1) +#define FE_ISDBT (FE_DTMB + 1) + +struct fe_blind_scan_parameters { + /* minimum tuner frequency in kHz */ + __u32 min_frequency; + /* maximum tuner frequency in kHz */ + __u32 max_frequency; + /* minimum symbol rate in sym/sec */ + __u32 min_symbol_rate; + /* maximum symbol rate in sym/sec */ + __u32 max_symbol_rate; + /* search range in kHz. freq -/+freqRange will be searched */ + __u32 frequency_range; + /* tuner step frequency in kHz */ + __u32 frequency_step; + /* blindscan event timeout */ + __s32 timeout; +}; + +#define DTV_DVBT2_PLP_ID DTV_DVBT2_PLP_ID_LEGACY + +#define BLINDSCAN_NONEDO 0x80 /* not blind scan */ +#define BLINDSCAN_UPDATESTARTFREQ 0x100 /* blind scan update start freq */ +#define BLINDSCAN_UPDATEPROCESS 0x20 /* blind scan update process */ +#define BLINDSCAN_UPDATERESULTFREQ 0x400 /* blind scan update result */ + +/* Get tne TS input of the frontend */ +#define DTV_TS_INPUT 100 +/* Blind scan */ +#define DTV_START_BLIND_SCAN 101 +#define DTV_CANCEL_BLIND_SCAN 102 +#define DTV_BLIND_SCAN_MIN_FRE 103 +#define DTV_BLIND_SCAN_MAX_FRE 104 +#define DTV_BLIND_SCAN_MIN_SRATE 105 +#define DTV_BLIND_SCAN_MAX_SRATE 106 +#define DTV_BLIND_SCAN_FRE_RANGE 107 +#define DTV_BLIND_SCAN_FRE_STEP 108 +#define DTV_BLIND_SCAN_TIMEOUT 109 +#define DTV_SINGLE_CABLE_VER 110 +#define DTV_SINGLE_CABLE_USER_BAND 111 +#define DTV_SINGLE_CABLE_BAND_FRE 112 +#define DTV_SINGLE_CABLE_BANK 113 +#define DTV_SINGLE_CABLE_UNCOMMITTED 114 +#define DTV_SINGLE_CABLE_COMMITTED 115 +/* Blind scan end*/ +#define DTV_DELIVERY_SUB_SYSTEM 116 +#define AML_DTV_MAX_COMMAND DTV_DELIVERY_SUB_SYSTEM + +#define SYS_ANALOG (SYS_DVBC_ANNEX_C + 1) + +enum fe_ofdm_mode { + OFDM_DVBT, + OFDM_DVBT2, +}; + +/*#define ANALOG_FLAG_ENABLE_AFC 0X00000001*/ +#define ANALOG_FLAG_MANUL_SCAN 0x00000011 +struct dvb_analog_parameters { + /*V4L2_TUNER_MODE_MONO,V4L2_TUNER_MODE_STEREO,*/ + /*V4L2_TUNER_MODE_LANG2,V4L2_TUNER_MODE_SAP,*/ + /*V4L2_TUNER_MODE_LANG1,V4L2_TUNER_MODE_LANG1_LANG2 */ + unsigned int audmode; + unsigned int soundsys; /*A2,BTSC,EIAJ,NICAM */ + v4l2_std_id std; + unsigned int flag; + unsigned int afc_range; +}; + +/* Satellite blind scan event */ + +/*struct dvb_frontend_parameters; */ +/*struct dvbsx_blindscanevent { */ +/* enum fe_status status; */ +/* union {*/ + /* The percentage completion of the*/ + /*blind scan procedure. A value of*/ + /*100 indicates that the blind scan*/ + /*is finished. */ + /*__u16 m_uiprogress;*/ + /*The start scan frequency in units of kHz.*/ + /*The minimum value depends on the tuner*/ + /*specification.*/ + /*__u32 m_uistartfreq_khz;*/ + /* Blind scan channel info. */ + /*struct dvb_frontend_parameters parameters;*/ + /*} u;*/ +/*};*/ + +/*for atv*/ +struct tuner_status_s { + unsigned int frequency; + unsigned int rssi; + unsigned char mode;/*dtv:0 or atv:1*/ + unsigned char tuner_locked;/*notlocked:0,locked:1*/ + union { + void *ressrved; + __u64 reserved1; + }; +}; + +struct atv_status_s { + unsigned char atv_lock;/*notlocked:0,locked 1*/ + v4l2_std_id std; + unsigned int audmode; + int snr; + int afc; + union { + void *resrvred; + __u64 reserved1; + }; +}; + +struct sound_status_s { + unsigned short sound_sys;/*A2DK/A2BG/NICAM BG/NICAM DK/BTSC/EIAJ*/ + unsigned short sound_mode;/*SETERO/DUAL/MONO/SAP*/ + union { + void *resrvred; + __u64 reserved1; + }; +}; + +enum tuner_param_cmd_e { + TUNER_CMD_AUDIO_MUTE = 0x0000, + TUNER_CMD_AUDIO_ON, + TUNER_CMD_TUNER_POWER_ON, + TUNER_CMD_TUNER_POWER_DOWN, + TUNER_CMD_SET_VOLUME, + TUNER_CMD_SET_LEAP_SETP_SIZE, + TUNER_CMD_GET_MONO_MODE, + TUNER_CMD_SET_BEST_LOCK_RANGE, + TUNER_CMD_GET_BEST_LOCK_RANGE, + TUNER_CMD_SET_CVBS_AMP_OUT, + TUNER_CMD_GET_CVBS_AMP_OUT, + TUNER_CMD_NULL, +}; + +/*parameter for set param box*/ +struct tuner_param_s { + enum tuner_param_cmd_e cmd; + unsigned int parm; + unsigned int resvred; +}; + +/* typedef struct dvb_analog_parameters dvb_analog_parameters_t; */ +/* typedef struct tuner_status_s tuner_status_t; */ +/* typedef struct atv_status_s atv_status_t; */ +/* typedef struct sound_status_s sound_status_t; */ +/* typedef enum tuner_param_cmd_e tuner_param_cmd_t; */ +/* typedef struct tuner_param_s tuner_param_t; */ +/* typedef enum fe_layer fe_layer_t; */ +/* typedef enum fe_ofdm_mode fe_ofdm_mode_t; */ + +/* Satellite blind scan settings */ +struct dvbsx_blindscanpara { + __u32 minfrequency;/* minimum tuner frequency in kHz */ + __u32 maxfrequency;/* maximum tuner frequency in kHz */ + __u32 minSymbolRate;/* minimum symbol rate in sym/sec */ + __u32 maxSymbolRate;/* maximum symbol rate in sym/sec */ + /*search range in kHz. freq -/+freqRange will be searched */ + __u32 frequencyRange; + __u32 frequencyStep;/* tuner step frequency in kHz */ + __s32 timeout;/* blindscan event timeout*/ +}; + +struct dvbsx_singlecable_parameters { + /* not singlecable: 0, 1.0X - 1(EN50494), 2.0X - 2(EN50607) */ + __u32 version; + __u32 userband; /* 1.0X: 0 - 7, 2.0X: 0 - 31 */ + __u32 frequency; /* KHz */ + __u32 bank; + /* + * Uncommitted switches setting for SCD2 (Similar to DiSEqC WriteN1 command, + * but lower 4 bits only) + * Bit[0] : Switch 1 Position A or B + * Bit[1] : Switch 2 Position A or B + * Bit[2] : Switch 3 Position A or B + * Bit[3] : Switch 4 Position A or B + */ + __u32 uncommitted; + /* + * Committed switches setting for SCD2 (Similar to DiSEqC WriteN0 command, + * but lower 4 bits only) + * Bit[0] : Low or High Band + * Bit[1] : Vertical or Horizontal Polarization + * Bit[2] : Satellite Position A or B + * Bit[3] : Option Switch Position A or B + */ + __u32 committed; +}; + +#endif /*_AML_FE_EXT_H_*/ diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h index 2e88f83bf184..4f9b4551c534 100644 --- a/include/uapi/linux/dvb/frontend.h +++ b/include/uapi/linux/dvb/frontend.h @@ -29,10 +29,6 @@ #include -/* amlogic define */ -#include -/* amlogic define end */ - /** * enum fe_caps - Frontend capabilities * @@ -114,13 +110,9 @@ enum fe_type { FE_QPSK, FE_QAM, FE_OFDM, - FE_ATSC, - /*amlogic define*/ - FE_ANALOG, - FE_DTMB, - FE_ISDBT - /*amlogic define end*/ + FE_ATSC }; + /** * struct dvb_frontend_info - Frontend properties and capabilities * @@ -266,12 +258,6 @@ enum fe_status { FE_HAS_LOCK = 0x10, FE_TIMEDOUT = 0x20, FE_REINIT = 0x40, - /*amlogic define*/ - BLINDSCAN_NONEDO = 0x80, /* not blind scan */ - BLINDSCAN_UPDATESTARTFREQ = 0x100, /* blind scan update start freq */ - BLINDSCAN_UPDATEPROCESS = 0x200, /* blind scan update process */ - BLINDSCAN_UPDATERESULTFREQ = 0x400/* blind scan update result */ - /*amlogic define end*/ }; /** @@ -469,26 +455,6 @@ enum fe_interleaving { INTERLEAVING_720, }; -/*amlogic define*/ -struct fe_blind_scan_parameters { - /* minimum tuner frequency in kHz */ - __u32 min_frequency; - /* maximum tuner frequency in kHz */ - __u32 max_frequency; - /* minimum symbol rate in sym/sec */ - __u32 min_symbol_rate; - /* maximum symbol rate in sym/sec */ - __u32 max_symbol_rate; - /* search range in kHz. freq -/+freqRange will be searched */ - __u32 frequency_range; - /* tuner step frequency in kHz */ - __u32 frequency_step; - /* blindscan event timeout */ - __s32 timeout; -}; - -/*amlogic define end*/ - /* DVBv5 property Commands */ #define DTV_UNDEFINED 0 @@ -550,9 +516,6 @@ struct fe_blind_scan_parameters { #define DTV_DVBT2_PLP_ID_LEGACY 43 #define DTV_ENUM_DELSYS 44 -/*amlogic define*/ -#define DTV_DVBT2_PLP_ID DTV_DVBT2_PLP_ID_LEGACY -/*amlogic define end*/ /* ATSC-MH */ #define DTV_ATSCMH_FIC_VER 45 @@ -587,29 +550,8 @@ struct fe_blind_scan_parameters { /* Physical layer scrambling */ #define DTV_SCRAMBLING_SEQUENCE_INDEX 70 -/* amlogic define */ -/* Get tne TS input of the frontend */ -#define DTV_TS_INPUT 100 -/* Blind scan */ -#define DTV_START_BLIND_SCAN 101 -#define DTV_CANCEL_BLIND_SCAN 102 -#define DTV_BLIND_SCAN_MIN_FRE 103 -#define DTV_BLIND_SCAN_MAX_FRE 104 -#define DTV_BLIND_SCAN_MIN_SRATE 105 -#define DTV_BLIND_SCAN_MAX_SRATE 106 -#define DTV_BLIND_SCAN_FRE_RANGE 107 -#define DTV_BLIND_SCAN_FRE_STEP 108 -#define DTV_BLIND_SCAN_TIMEOUT 109 -#define DTV_SINGLE_CABLE_VER 110 -#define DTV_SINGLE_CABLE_USER_BAND 111 -#define DTV_SINGLE_CABLE_BAND_FRE 112 -#define DTV_SINGLE_CABLE_BANK 113 -#define DTV_SINGLE_CABLE_UNCOMMITTED 114 -#define DTV_SINGLE_CABLE_COMMITTED 115 -/* Blind scan end*/ -#define DTV_DELIVERY_SUB_SYSTEM 116 -#define DTV_MAX_COMMAND DTV_DELIVERY_SUB_SYSTEM -/* amlogic define end */ +#define DTV_MAX_COMMAND DTV_SCRAMBLING_SEQUENCE_INDEX + /** * enum fe_pilot - Type of pilot tone * @@ -703,9 +645,6 @@ enum fe_delivery_system { SYS_DVBT2, SYS_TURBO, SYS_DVBC_ANNEX_C, - /* amlogic define */ - SYS_ANALOG - /* amlogic define end */ }; /* backward compatibility definitions for delivery systems */ @@ -1018,14 +957,6 @@ typedef enum fe_pilot fe_pilot_t; typedef enum fe_rolloff fe_rolloff_t; typedef enum fe_delivery_system fe_delivery_system_t; -/* amlogic define */ -enum fe_ofdm_mode { - OFDM_DVBT, - OFDM_DVBT2, -}; - -/* amlogic define end */ - /* DVBv3 structs */ struct dvb_qpsk_parameters { @@ -1053,21 +984,6 @@ struct dvb_ofdm_parameters { fe_hierarchy_t hierarchy_information; }; -/* amlogic define */ -#define ANALOG_FLAG_ENABLE_AFC 0X00000001 -#define ANALOG_FLAG_MANUL_SCAN 0x00000011 -struct dvb_analog_parameters { - /*V4L2_TUNER_MODE_MONO,V4L2_TUNER_MODE_STEREO,*/ - /*V4L2_TUNER_MODE_LANG2,V4L2_TUNER_MODE_SAP,*/ - /*V4L2_TUNER_MODE_LANG1,V4L2_TUNER_MODE_LANG1_LANG2 */ - unsigned int audmode; - unsigned int soundsys; /*A2,BTSC,EIAJ,NICAM */ - v4l2_std_id std; - unsigned int flag; - unsigned int afc_range; -}; - -/* amlogic define end */ struct dvb_frontend_parameters { __u32 frequency; /* (absolute) frequency in Hz for DVB-C/DVB-T/ATSC */ /* intermediate frequency in kHz for DVB-S */ @@ -1085,103 +1001,6 @@ struct dvb_frontend_event { struct dvb_frontend_parameters parameters; }; -/* amlogic define */ -/* Satellite blind scan event */ -struct dvbsx_blindscanevent { - enum fe_status status; - union { - /* The percentage completion of the*/ - /*blind scan procedure. A value of*/ - /*100 indicates that the blind scan*/ - /*is finished. */ - __u16 m_uiprogress; - /*The start scan frequency in units of kHz.*/ - /*The minimum value depends on the tuner*/ - /*specification.*/ - __u32 m_uistartfreq_khz; - /* Blind scan channel info. */ - struct dvb_frontend_parameters parameters; - } u; -}; - -/*for atv*/ -struct tuner_status_s { - unsigned int frequency; - unsigned int rssi; - unsigned char mode;/*dtv:0 or atv:1*/ - unsigned char tuner_locked;/*notlocked:0,locked:1*/ - union { - void *ressrved; - __u64 reserved1; - }; -}; - -struct atv_status_s { - unsigned char atv_lock;/*notlocked:0,locked 1*/ - v4l2_std_id std; - unsigned int audmode; - int snr; - int afc; - union { - void *resrvred; - __u64 reserved1; - }; -}; - -struct sound_status_s { - unsigned short sound_sys;/*A2DK/A2BG/NICAM BG/NICAM DK/BTSC/EIAJ*/ - unsigned short sound_mode;/*SETERO/DUAL/MONO/SAP*/ - union { - void *resrvred; - __u64 reserved1; - }; -}; - -enum tuner_param_cmd_e { - TUNER_CMD_AUDIO_MUTE = 0x0000, - TUNER_CMD_AUDIO_ON, - TUNER_CMD_TUNER_POWER_ON, - TUNER_CMD_TUNER_POWER_DOWN, - TUNER_CMD_SET_VOLUME, - TUNER_CMD_SET_LEAP_SETP_SIZE, - TUNER_CMD_GET_MONO_MODE, - TUNER_CMD_SET_BEST_LOCK_RANGE, - TUNER_CMD_GET_BEST_LOCK_RANGE, - TUNER_CMD_SET_CVBS_AMP_OUT, - TUNER_CMD_GET_CVBS_AMP_OUT, - TUNER_CMD_NULL, -}; - -/*parameter for set param box*/ -struct tuner_param_s { - enum tuner_param_cmd_e cmd; - unsigned int parm; - unsigned int resvred; -}; - -/* typedef struct dvb_analog_parameters dvb_analog_parameters_t; */ -/* typedef struct tuner_status_s tuner_status_t; */ -/* typedef struct atv_status_s atv_status_t; */ -/* typedef struct sound_status_s sound_status_t; */ -/* typedef enum tuner_param_cmd_e tuner_param_cmd_t; */ -/* typedef struct tuner_param_s tuner_param_t; */ -/* typedef enum fe_layer fe_layer_t; */ -/* typedef enum fe_ofdm_mode fe_ofdm_mode_t; */ - -/* Satellite blind scan settings */ -struct dvbsx_blindscanpara { - __u32 minfrequency;/* minimum tuner frequency in kHz */ - __u32 maxfrequency;/* maximum tuner frequency in kHz */ - __u32 minSymbolRate;/* minimum symbol rate in sym/sec */ - __u32 maxSymbolRate;/* maximum symbol rate in sym/sec */ - /*search range in kHz. freq -/+freqRange will be searched */ - __u32 frequencyRange; - __u32 frequencyStep;/* tuner step frequency in kHz */ - __s32 timeout;/* blindscan event timeout*/ -}; - -/* amlogic define end */ - /* DVBv3 API calls */ #define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters) @@ -1189,33 +1008,4 @@ struct dvbsx_blindscanpara { #endif -/* amlogic define */ -struct dvbsx_singlecable_parameters { - /* not singlecable: 0, 1.0X - 1(EN50494), 2.0X - 2(EN50607) */ - __u32 version; - __u32 userband; /* 1.0X: 0 - 7, 2.0X: 0 - 31 */ - __u32 frequency; /* KHz */ - __u32 bank; - /* - * Uncommitted switches setting for SCD2 (Similar to DiSEqC WriteN1 command, - * but lower 4 bits only) - * Bit[0] : Switch 1 Position A or B - * Bit[1] : Switch 2 Position A or B - * Bit[2] : Switch 3 Position A or B - * Bit[3] : Switch 4 Position A or B - */ - __u32 uncommitted; - /* - * Committed switches setting for SCD2 (Similar to DiSEqC WriteN0 command, - * but lower 4 bits only) - * Bit[0] : Low or High Band - * Bit[1] : Vertical or Horizontal Polarization - * Bit[2] : Satellite Position A or B - * Bit[3] : Option Switch Position A or B - */ - __u32 committed; -}; - -/* amlogic define end */ - #endif /*_DVBFRONTEND_H_*/