浏览代码

[media] media: ti-vpe: Make scaler library into its own module

In preparation to add scaler support into VIP we need to
turn sc.c into its own kernel module.

Add support for multiple SC memory block as VIP contains
2 scaler instances.
This is done by passing the resource name to sc_create() and
modify the vpe invocation accordingly.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Benoit Parrot 8 年之前
父节点
当前提交
1c6e81783c

+ 4 - 0
drivers/media/platform/Kconfig

@@ -365,6 +365,7 @@ config VIDEO_TI_VPE
 	select VIDEOBUF2_DMA_CONTIG
 	select VIDEOBUF2_DMA_CONTIG
 	select V4L2_MEM2MEM_DEV
 	select V4L2_MEM2MEM_DEV
 	select VIDEO_TI_VPDMA
 	select VIDEO_TI_VPDMA
+	select VIDEO_TI_SC
 	default n
 	default n
 	---help---
 	---help---
 	  Support for the TI VPE(Video Processing Engine) block
 	  Support for the TI VPE(Video Processing Engine) block
@@ -383,6 +384,9 @@ endif # V4L_MEM2MEM_DRIVERS
 config VIDEO_TI_VPDMA
 config VIDEO_TI_VPDMA
 	tristate
 	tristate
 
 
+config VIDEO_TI_SC
+	tristate
+
 menuconfig V4L_TEST_DRIVERS
 menuconfig V4L_TEST_DRIVERS
 	bool "Media test drivers"
 	bool "Media test drivers"
 	depends on MEDIA_CAMERA_SUPPORT
 	depends on MEDIA_CAMERA_SUPPORT

+ 3 - 1
drivers/media/platform/ti-vpe/Makefile

@@ -1,8 +1,10 @@
 obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o
 obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o
 obj-$(CONFIG_VIDEO_TI_VPDMA) += ti-vpdma.o
 obj-$(CONFIG_VIDEO_TI_VPDMA) += ti-vpdma.o
+obj-$(CONFIG_VIDEO_TI_SC) += ti-sc.o
 
 
-ti-vpe-y := vpe.o sc.o csc.o
+ti-vpe-y := vpe.o csc.o
 ti-vpdma-y := vpdma.o
 ti-vpdma-y := vpdma.o
+ti-sc-y := sc.o
 
 
 ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG
 ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG
 
 

+ 14 - 3
drivers/media/platform/ti-vpe/sc.c

@@ -14,6 +14,7 @@
 
 
 #include <linux/err.h>
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/io.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/slab.h>
 
 
@@ -52,6 +53,7 @@ void sc_dump_regs(struct sc_data *sc)
 
 
 #undef DUMPREG
 #undef DUMPREG
 }
 }
+EXPORT_SYMBOL(sc_dump_regs);
 
 
 /*
 /*
  * set the horizontal scaler coefficients according to the ratio of output to
  * set the horizontal scaler coefficients according to the ratio of output to
@@ -100,6 +102,7 @@ void sc_set_hs_coeffs(struct sc_data *sc, void *addr, unsigned int src_w,
 
 
 	sc->load_coeff_h = true;
 	sc->load_coeff_h = true;
 }
 }
+EXPORT_SYMBOL(sc_set_hs_coeffs);
 
 
 /*
 /*
  * set the vertical scaler coefficients according to the ratio of output to
  * set the vertical scaler coefficients according to the ratio of output to
@@ -140,6 +143,7 @@ void sc_set_vs_coeffs(struct sc_data *sc, void *addr, unsigned int src_h,
 
 
 	sc->load_coeff_v = true;
 	sc->load_coeff_v = true;
 }
 }
+EXPORT_SYMBOL(sc_set_vs_coeffs);
 
 
 void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8,
 void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8,
 		u32 *sc_reg17, unsigned int src_w, unsigned int src_h,
 		u32 *sc_reg17, unsigned int src_w, unsigned int src_h,
@@ -267,8 +271,9 @@ void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8,
 
 
 	*sc_reg24 = (src_w << CFG_ORG_W_SHIFT) | (src_h << CFG_ORG_H_SHIFT);
 	*sc_reg24 = (src_w << CFG_ORG_W_SHIFT) | (src_h << CFG_ORG_H_SHIFT);
 }
 }
+EXPORT_SYMBOL(sc_config_scaler);
 
 
-struct sc_data *sc_create(struct platform_device *pdev)
+struct sc_data *sc_create(struct platform_device *pdev, const char *res_name)
 {
 {
 	struct sc_data *sc;
 	struct sc_data *sc;
 
 
@@ -282,9 +287,10 @@ struct sc_data *sc_create(struct platform_device *pdev)
 
 
 	sc->pdev = pdev;
 	sc->pdev = pdev;
 
 
-	sc->res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sc");
+	sc->res = platform_get_resource_byname(pdev, IORESOURCE_MEM, res_name);
 	if (!sc->res) {
 	if (!sc->res) {
-		dev_err(&pdev->dev, "missing platform resources data\n");
+		dev_err(&pdev->dev, "missing '%s' platform resources data\n",
+			res_name);
 		return ERR_PTR(-ENODEV);
 		return ERR_PTR(-ENODEV);
 	}
 	}
 
 
@@ -296,3 +302,8 @@ struct sc_data *sc_create(struct platform_device *pdev)
 
 
 	return sc;
 	return sc;
 }
 }
+EXPORT_SYMBOL(sc_create);
+
+MODULE_DESCRIPTION("TI VIP/VPE Scaler");
+MODULE_AUTHOR("Texas Instruments Inc.");
+MODULE_LICENSE("GPL v2");

+ 1 - 1
drivers/media/platform/ti-vpe/sc.h

@@ -200,6 +200,6 @@ void sc_set_vs_coeffs(struct sc_data *sc, void *addr, unsigned int src_h,
 void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8,
 void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8,
 		u32 *sc_reg17, unsigned int src_w, unsigned int src_h,
 		u32 *sc_reg17, unsigned int src_w, unsigned int src_h,
 		unsigned int dst_w, unsigned int dst_h);
 		unsigned int dst_w, unsigned int dst_h);
-struct sc_data *sc_create(struct platform_device *pdev);
+struct sc_data *sc_create(struct platform_device *pdev, const char *res_name);
 
 
 #endif
 #endif

+ 1 - 1
drivers/media/platform/ti-vpe/vpe.c

@@ -2453,7 +2453,7 @@ static int vpe_probe(struct platform_device *pdev)
 
 
 	vpe_top_vpdma_reset(dev);
 	vpe_top_vpdma_reset(dev);
 
 
-	dev->sc = sc_create(pdev);
+	dev->sc = sc_create(pdev, "sc");
 	if (IS_ERR(dev->sc)) {
 	if (IS_ERR(dev->sc)) {
 		ret = PTR_ERR(dev->sc);
 		ret = PTR_ERR(dev->sc);
 		goto runtime_put;
 		goto runtime_put;