dvb: add 32/64 bits compatibility support
authorKe Gong <ke.gong@amlogic.com>
Fri, 17 Mar 2017 02:40:14 +0000 (10:40 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 5 Apr 2017 12:45:33 +0000 (20:45 +0800)
PD#138714: add 32/64 bits compatibility support for dvb

1.add 32/64 bits compatibility support for dvb
2.add extension descrambler setting interface in CA
3.add DTV_TS_INPUT property
4.add CONFIG_AMLOGIC_DVB_COMPAT

Change-Id: Ifb48e1671446f3ac14db764b39ab1535950f177a
Signed-off-by: Ke Gong <ke.gong@amlogic.com>
arch/arm64/configs/meson64_defconfig
drivers/amlogic/Kconfig
drivers/amlogic/dvb/Kconfig [new file with mode: 0644]
drivers/media/dvb-core/dmxdev.c
drivers/media/dvb-core/dvb_ca_en50221.c
drivers/media/dvb-core/dvb_frontend.c
include/uapi/linux/dvb/ca.h
include/uapi/linux/dvb/dmx.h
include/uapi/linux/dvb/frontend.h

index 72ac3ff341c4d77be80cde2993c7e1de6bf731ca..007ef4d5bdc2f803afb7781a5f82c8896d896723 100644 (file)
@@ -246,6 +246,7 @@ CONFIG_AMLOGIC_WDT=y
 CONFIG_AMLOGIC_WDT_MESON=y
 CONFIG_AMLOGIC_WIFI=y
 CONFIG_AMLOGIC_BT_DEVICE=y
+CONFIG_AMLOGIC_DVB_COMPAT=y
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
index b8f5a505bdfd2f7fd20afe6e65ccad3700bcc97e..fbaf77ed071a0c5bda976d55db960bedfef4bf47 100644 (file)
@@ -8,6 +8,7 @@ config AMLOGIC_DRIVER
                this option is provided for control amlogic
                drivers, if you want to use amlogic driver
                please open it
+
 if AMLOGIC_DRIVER
 menu "Amlogic Device Drivers"
 
@@ -83,5 +84,7 @@ source "drivers/amlogic/wifi/Kconfig"
 
 source "drivers/amlogic/bluetooth/Kconfig"
 
+source "drivers/amlogic/dvb/Kconfig"
+
 endmenu
 endif
diff --git a/drivers/amlogic/dvb/Kconfig b/drivers/amlogic/dvb/Kconfig
new file mode 100644 (file)
index 0000000..b1ce589
--- /dev/null
@@ -0,0 +1,7 @@
+menu "DVB COMPAT support"
+config AMLOGIC_DVB_COMPAT
+       bool "Amlogic DVB drivers"
+       depends on COMPAT
+       help
+               select it to support amlogic dvb driver
+endmenu
index 7b67e1dd97fd75693704f3a2e20479876212fc1f..0d1fca15b4db0c11f6cdcc04442d08f265cdbea4 100644 (file)
@@ -1128,6 +1128,18 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
        return ret;
 }
 
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+static long dvb_demux_compat_ioctl(struct file *filp,
+                       unsigned int cmd, unsigned long args)
+{
+       unsigned long ret;
+
+       args = (unsigned long)compat_ptr(args);
+       ret = dvb_demux_ioctl(filp, cmd, args);
+       return ret;
+}
+#endif
+
 static const struct file_operations dvb_demux_fops = {
        .owner = THIS_MODULE,
        .read = dvb_demux_read,
@@ -1136,6 +1148,9 @@ static const struct file_operations dvb_demux_fops = {
        .release = dvb_demux_release,
        .poll = dvb_demux_poll,
        .llseek = default_llseek,
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+       .compat_ioctl   = dvb_demux_compat_ioctl,
+#endif
 };
 
 static const struct dvb_device dvbdev_demux = {
@@ -1203,6 +1218,18 @@ static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
        return mask;
 }
 
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+static long dvb_dvr_compat_ioctl(struct file *filp,
+                       unsigned int cmd, unsigned long args)
+{
+       unsigned long ret;
+
+       args = (unsigned long)compat_ptr(args);
+       ret = dvb_dvr_ioctl(filp, cmd, args);
+       return ret;
+}
+#endif
+
 static const struct file_operations dvb_dvr_fops = {
        .owner = THIS_MODULE,
        .read = dvb_dvr_read,
@@ -1212,6 +1239,9 @@ static const struct file_operations dvb_dvr_fops = {
        .release = dvb_dvr_release,
        .poll = dvb_dvr_poll,
        .llseek = default_llseek,
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+       .compat_ioctl   = dvb_dvr_compat_ioctl,
+#endif
 };
 
 static const struct dvb_device dvbdev_dvr = {
index b5b5b195ea7f04d1feb40b2967b43cb174b1bf7e..e103c563ea3f2436893945916e9118270c175ab8 100644 (file)
@@ -1660,6 +1660,17 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
 }
 EXPORT_SYMBOL(dvb_ca_en50221_init);
 
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+static long dvb_ca_en50221_compat_ioctl(struct file *filp,
+                       unsigned int cmd, unsigned long args)
+{
+       unsigned long ret;
+
+       args = (unsigned long)compat_ptr(args);
+       ret = dvb_ca_en50221_io_ioctl(filp, cmd, args);
+       return ret;
+}
+#endif
 
 static const struct file_operations dvb_ca_fops = {
        .owner = THIS_MODULE,
@@ -1670,6 +1681,9 @@ static const struct file_operations dvb_ca_fops = {
        .release = dvb_ca_en50221_io_release,
        .poll = dvb_ca_en50221_io_poll,
        .llseek = noop_llseek,
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+       .compat_ioctl   = dvb_ca_en50221_compat_ioctl,
+#endif
 };
 
 static const struct dvb_device dvbdev_ca = {
index 01511e5a5566643a32d03ba64fe314c299860ef6..e1424495d57469b1a553a00f76745ae5a291e42e 100644 (file)
@@ -2600,6 +2600,30 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
        return ret;
 }
 
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+static long dvb_frontend_compat_ioctl(struct file *filp,
+                       unsigned int cmd, unsigned long args)
+{
+       unsigned long ret;
+       struct dtv_properties tvps;
+
+       args  = (unsigned long)compat_ptr(args);
+
+       if ((cmd == FE_SET_PROPERTY) || (cmd == FE_GET_PROPERTY)) {
+               if (copy_from_user(&tvps, (void *)args,
+                       sizeof(struct dtv_properties)))
+                       return -EFAULT;
+               tvps.props = compat_ptr((unsigned long)tvps.props);
+               if (copy_to_user((void *)args, (void *)&tvps,
+                       sizeof(struct dtv_properties)))
+                       return -EFAULT;
+       }
+
+       ret = dvb_generic_ioctl(filp, cmd, args);
+       return ret;
+}
+#endif
+
 static const struct file_operations dvb_frontend_fops = {
        .owner          = THIS_MODULE,
        .unlocked_ioctl = dvb_generic_ioctl,
@@ -2607,6 +2631,9 @@ static const struct file_operations dvb_frontend_fops = {
        .open           = dvb_frontend_open,
        .release        = dvb_frontend_release,
        .llseek         = noop_llseek,
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+       .compat_ioctl   = dvb_frontend_compat_ioctl,
+#endif
 };
 
 int dvb_frontend_suspend(struct dvb_frontend *fe)
index c18537f3e449bb219a1b48f1b9e46c1c3aa00820..e7902227ece9609cbfc6640685563d4fe0021349 100644 (file)
@@ -73,6 +73,28 @@ typedef struct ca_descr {
        unsigned char cw[8];
 } ca_descr_t;
 
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+
+/* CW type. */
+enum ca_cw_type {
+       CA_CW_DVB_CSA_EVEN,
+       CA_CW_DVB_CSA_ODD,
+       CA_CW_AES_EVEN,
+       CA_CW_AES_ODD,
+       CA_CW_AES_EVEN_IV,
+       CA_CW_AES_ODD_IV
+};
+
+struct ca_descr_ex {
+       unsigned int index;
+       enum ca_cw_type type;
+       int          flags;
+#define CA_CW_FROM_KL 1
+       unsigned char cw[16];
+};
+
+#endif /*CONFIG_AMLOGIC_DVB_COMPAT*/
+
 typedef struct ca_pid {
        unsigned int pid;
        int index;              /* -1 == disable*/
@@ -87,4 +109,8 @@ typedef struct ca_pid {
 #define CA_SET_DESCR      _IOW('o', 134, ca_descr_t)
 #define CA_SET_PID        _IOW('o', 135, ca_pid_t)
 
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+#define CA_SET_DESCR_EX   _IOW('o', 200, struct ca_descr_ex)
+#endif
+
 #endif
index 427e4899ed69acd1ab31722b7723ad15db290a04..1c03fe50bd0565b6ac18c01f06bf6b0501f53903 100644 (file)
@@ -106,6 +106,10 @@ struct dmx_sct_filter_params
 #define DMX_ONESHOT         2
 #define DMX_IMMEDIATE_START 4
 #define DMX_KERNEL_CLIENT   0x8000
+
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+#define DMX_USE_SWFILTER    0x100
+#endif
 };
 
 
@@ -131,7 +135,13 @@ typedef enum dmx_source {
        DMX_SOURCE_DVR0   = 16,
        DMX_SOURCE_DVR1,
        DMX_SOURCE_DVR2,
-       DMX_SOURCE_DVR3
+       DMX_SOURCE_DVR3,
+
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+       DMX_SOURCE_FRONT0_OFFSET = 100,
+       DMX_SOURCE_FRONT1_OFFSET,
+       DMX_SOURCE_FRONT2_OFFSET
+#endif
 } dmx_source_t;
 
 struct dmx_stc {
index 00a20cd21ee230dabd55954d58209d1e59025d24..cca0186eaae978087ae38baeca734fc168bf1162 100644 (file)
@@ -216,6 +216,25 @@ enum fe_interleaving {
        INTERLEAVING_720,
 };
 
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+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;
+};
+#endif
+
 /* S2API Commands */
 #define DTV_UNDEFINED          0
 #define DTV_TUNE               1
@@ -307,8 +326,24 @@ enum fe_interleaving {
 #define DTV_STAT_ERROR_BLOCK_COUNT     68
 #define DTV_STAT_TOTAL_BLOCK_COUNT     69
 
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+
+/* Get tne TS input of the frontend */
+#define DTV_TS_INPUT                    70
+/* Blind scan */
+#define DTV_START_BLIND_SCAN            71
+#define DTV_CANCEL_BLIND_SCAN           72
+#define DTV_BLIND_SCAN_STATUS           73
+
+#define DTV_MAX_COMMAND                DTV_BLIND_SCAN_STATUS
+
+#else  /*!defined(CONFIG_AMLOGIC_DVB_COMPAT)*/
+
 #define DTV_MAX_COMMAND                DTV_STAT_TOTAL_BLOCK_COUNT
 
+#endif /*CONFIG_AMLOGIC_DVB_COMPAT*/
+
+
 enum fe_pilot {
        PILOT_ON,
        PILOT_OFF,
@@ -481,7 +516,14 @@ struct dtv_property {
 
 struct dtv_properties {
        __u32 num;
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+       union {
+               struct dtv_property *props;
+               __u64                reserved;
+       };
+#else
        struct dtv_property *props;
+#endif
 };
 
 #if defined(__DVB_CORE__) || !defined (__KERNEL__)
@@ -557,6 +599,28 @@ struct dvb_frontend_parameters {
        } u;
 };
 
+#ifdef CONFIG_AMLOGIC_DVB_COMPAT
+
+struct dvb_frontend_parameters_ex {
+       __u32 frequency;  /* (absolute) frequency in Hz for DVB-C/DVB-T/ATSC */
+                         /* intermediate frequency in kHz for DVB-S */
+       fe_spectral_inversion_t inversion;
+       union {
+               struct dvb_qpsk_parameters qpsk;        /* DVB-S */
+               struct dvb_qam_parameters  qam;         /* DVB-C */
+               struct dvb_ofdm_parameters ofdm;        /* DVB-T */
+               struct dvb_vsb_parameters vsb;          /* ATSC */
+               /* Add extenstion data here */
+       } u;
+};
+
+static char dvb_check_frontend_parameters_size[
+       (sizeof(struct dvb_frontend_parameters_ex)
+       == sizeof(struct dvb_frontend_parameters)) ? 1 : -1]
+       __attribute__((__unused__));
+
+#endif /*CONFIG_AMLOGIC_DVB_COMPAT*/
+
 struct dvb_frontend_event {
        fe_status_t status;
        struct dvb_frontend_parameters parameters;