IEP: add capabilities query interface
authoralpha.lin <alpha.lin@rock-chips.com>
Tue, 22 Sep 2015 08:44:04 +0000 (16:44 +0800)
committerGerrit Code Review <gerrit@rock-chips.com>
Wed, 23 Sep 2015 10:32:40 +0000 (18:32 +0800)
add capabilities query interface for userspace to query
iep device feature in current soc.

Change-Id: I377e686b2ce0357aa75445e4e47e9e4883a077ae
Signed-off-by: alpha.lin <alpha.lin@rock-chips.com>
arch/arm/boot/dts/rk312x.dtsi
arch/arm/boot/dts/rk3288.dtsi
arch/arm64/boot/dts/rk3368.dtsi
drivers/video/rockchip/iep/iep.h
drivers/video/rockchip/iep/iep_drv.c

index 0f989a07a8edc50ad2bf55c2a2c4ecf4e5a34895..33938f579375dce108a61b1cd7200b1265eba2b0 100755 (executable)
                interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&clk_gates9 8>, <&clk_gates9 7>;
                clock-names = "aclk_iep", "hclk_iep";
+               version = <1>;
                status = "okay";
        };
        
index f3af8822fb0d91b332a1c19ec61939815102ef9c..f838a5ce6de6ddf02e4c5f4e76dbdf0820c3a3b9 100644 (file)
                interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&clk_gates15 2>, <&clk_gates15 3>;
                clock-names = "aclk_iep", "hclk_iep";
+               version = <0>;
                status = "okay";
        };
 
index cbbe83b4494d6b83051a644f30f40863804804d2..f4dc91a3e8cd7b2088080d0ad42a803927249312 100644 (file)
                interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&clk_gates16 2>, <&clk_gates16 3>;
                clock-names = "aclk_iep", "hclk_iep";
+               version = <2>;
                status = "okay";
        };
 
index 63ad697dfc6eb65d5a7d834abbaed86d44038238..cf3753f7d55529ca61004f6b1dac797cf58343c5 100644 (file)
@@ -1,6 +1,24 @@
 #ifndef _IEP_H_
 #define _IEP_H_
 
+/* Capability for current iep version
+using by userspace to determine iep features */
+struct IEP_CAP {
+       u8 scaling_supported;
+       u8 i4_deinterlace_supported;
+       u8 i2_deinterlace_supported;
+       u8 compression_noise_reduction_supported;
+       u8 sampling_noise_reduction_supported;
+       u8 hsb_enhancement_supported;
+       u8 cg_enhancement_supported;
+       u8 direct_path_supported;
+       u16 max_dynamic_width;
+       u16 max_dynamic_height;
+       u16 max_static_width;
+       u16 max_static_height;
+       u8 max_enhance_radius;
+};
+
 #define IEP_IOC_MAGIC 'i'
 
 #define IEP_SET_PARAMETER_REQ          _IOW(IEP_IOC_MAGIC, 1, unsigned long)
@@ -13,6 +31,7 @@
 #define IEP_SET_PARAMETER              _IOW(IEP_IOC_MAGIC, 8, unsigned long)
 #define IEP_RELEASE_CURRENT_TASK       _IOW(IEP_IOC_MAGIC, 9, unsigned long)
 #define IEP_GET_IOMMU_STATE            _IOR(IEP_IOC_MAGIC,10, unsigned long)
+#define IEP_QUERY_CAP                  _IOR(IEP_IOC_MAGIC,11, struct IEP_CAP)
 
 #ifdef CONFIG_COMPAT
 #define COMPAT_IEP_SET_PARAMETER_REQ           _IOW(IEP_IOC_MAGIC, 1, u32)
@@ -25,6 +44,7 @@
 #define COMPAT_IEP_SET_PARAMETER               _IOW(IEP_IOC_MAGIC, 8, u32)
 #define COMPAT_IEP_RELEASE_CURRENT_TASK                _IOW(IEP_IOC_MAGIC, 9, u32)
 #define COMPAT_IEP_GET_IOMMU_STATE             _IOR(IEP_IOC_MAGIC,10, u32)
+#define COMPAT_IEP_QUERY_CAP                   _IOR(IEP_IOC_MAGIC,11, struct IEP_CAP)
 #endif
 
 /* Driver information */
@@ -36,7 +56,7 @@
 #define iep_debug(level, fmt, args...)                         \
        do {                                                    \
                if (debug >= level)                             \
-                       pr_info("%s:%d: " fmt,                  \
+                       pr_info("%s:%d: " fmt,                  \
                                 __func__, __LINE__, ##args);   \
        } while (0)
 #else
@@ -170,12 +190,11 @@ struct iep_img
        u8 alpha_swap;  /* not be used */
 };
 
-
 struct IEP_MSG {
        struct iep_img src;
        struct iep_img dst;
 
-       struct iep_img src1;   
+       struct iep_img src1;
        struct iep_img dst1;
 
        struct iep_img src_itemp;
index 5ac19f8c9e93489cbd71122fa4aec3c37b673349..b1bfb96f04938e69b806fd796f2459a25420fb4d 100644 (file)
@@ -77,6 +77,9 @@ struct iep_drvdata {
        atomic_t iep_int;
        atomic_t mmu_page_fault;
        atomic_t mmu_bus_error;
+
+       /* capability for this iep device */
+       struct IEP_CAP cap;
 };
 
 struct iep_drvdata *iep_drvdata1 = NULL;
@@ -800,6 +803,13 @@ static long iep_ioctl(struct file *filp, uint32_t cmd, unsigned long arg)
                        }
                }
                break;
+       case IEP_QUERY_CAP:
+               if (copy_to_user((void __user *)arg, &iep_drvdata1->cap,
+                       sizeof(struct IEP_CAP))) {
+                       IEP_ERR("error: copy_to_user failed\n");
+                       return -EFAULT;
+               }
+               break;
        default:
                IEP_ERR("unknown ioctl cmd!\n");
                ret = -EINVAL;
@@ -886,6 +896,13 @@ static long compat_iep_ioctl(struct file *filp, uint32_t cmd,
                        }
                }
                break;
+       case COMPAT_IEP_QUERY_CAP:
+               if (copy_to_user((void __user *)arg, &iep_drvdata1->cap,
+                       sizeof(struct IEP_CAP))) {
+                       IEP_ERR("error: copy_to_user failed\n");
+                       return -EFAULT;
+               }
+               break;
        default:
                IEP_ERR("unknown ioctl cmd!\n");
                ret = -EINVAL;
@@ -987,6 +1004,7 @@ static int iep_drv_probe(struct platform_device *pdev)
        struct iep_drvdata *data;
        int ret = 0;
        struct resource *res = NULL;
+       u32 version;
 #if defined(CONFIG_IEP_IOMMU)
        u32 iommu_en = 0;
        struct device *mmu_dev = NULL;
@@ -1070,6 +1088,46 @@ static int iep_drv_probe(struct platform_device *pdev)
 
        mutex_init(&iep_service.mutex);
 
+       if (of_property_read_u32(np, "version", &version)) {
+               version = 0;
+       }
+
+       data->cap.scaling_supported = 0;
+       data->cap.i4_deinterlace_supported = 1;
+       data->cap.i2_deinterlace_supported = 1;
+       data->cap.compression_noise_reduction_supported = 1;
+       data->cap.sampling_noise_reduction_supported = 1;
+       data->cap.hsb_enhancement_supported = 1;
+       data->cap.cg_enhancement_supported = 1;
+       data->cap.direct_path_supported = 1;
+       data->cap.max_dynamic_width = 1920;
+       data->cap.max_dynamic_height = 1088;
+       data->cap.max_static_width = 8192;
+       data->cap.max_static_height = 8192;
+       data->cap.max_enhance_radius = 3;
+
+       switch (version) {
+       case 0:
+               data->cap.scaling_supported = 1;
+               break;
+       case 1:
+               data->cap.compression_noise_reduction_supported = 0;
+               data->cap.sampling_noise_reduction_supported = 0;
+               if (soc_is_rk3126b()) {
+                       data->cap.i4_deinterlace_supported = 0;
+                       data->cap.hsb_enhancement_supported = 0;
+                       data->cap.cg_enhancement_supported = 0;
+               }
+               break;
+       case 2:
+               data->cap.max_dynamic_width = 4096;
+               data->cap.max_dynamic_height = 2340;
+               data->cap.max_enhance_radius = 2;
+               break;
+       default:
+               ;
+       }
+
        platform_set_drvdata(pdev, data);
 
        ret = misc_register(&iep_dev);