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 72ac3ff..007ef4d 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 b8f5a50..fbaf77e 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 7b67e1d..0d1fca1 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 b5b5b19..e103c56 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 01511e5..e142449 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 c18537f..e790222 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 427e489..1c03fe5 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 00a20cd..cca0186 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;