diff options
-rw-r--r-- | drivers/media/platform/ti-vpe/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/platform/ti-vpe/csc.c | 76 | ||||
-rw-r--r-- | drivers/media/platform/ti-vpe/csc.h | 65 | ||||
-rw-r--r-- | drivers/media/platform/ti-vpe/vpe.c | 31 | ||||
-rw-r--r-- | drivers/media/platform/ti-vpe/vpe_regs.h | 38 |
5 files changed, 155 insertions, 57 deletions
diff --git a/drivers/media/platform/ti-vpe/Makefile b/drivers/media/platform/ti-vpe/Makefile index 54c30b31c4cb..be680f839e77 100644 --- a/drivers/media/platform/ti-vpe/Makefile +++ b/drivers/media/platform/ti-vpe/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o | 1 | obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o |
2 | 2 | ||
3 | ti-vpe-y := vpe.o sc.o vpdma.o | 3 | ti-vpe-y := vpe.o sc.o csc.o vpdma.o |
4 | 4 | ||
5 | ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG | 5 | ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG |
diff --git a/drivers/media/platform/ti-vpe/csc.c b/drivers/media/platform/ti-vpe/csc.c new file mode 100644 index 000000000000..62e2fecd1798 --- /dev/null +++ b/drivers/media/platform/ti-vpe/csc.c | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Color space converter library | ||
3 | * | ||
4 | * Copyright (c) 2013 Texas Instruments Inc. | ||
5 | * | ||
6 | * David Griego, <dagriego@biglakesoftware.com> | ||
7 | * Dale Farnsworth, <dale@farnsworth.org> | ||
8 | * Archit Taneja, <archit@ti.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License version 2 as published by | ||
12 | * the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/err.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/slab.h> | ||
19 | |||
20 | #include "csc.h" | ||
21 | |||
22 | void csc_dump_regs(struct csc_data *csc) | ||
23 | { | ||
24 | struct device *dev = &csc->pdev->dev; | ||
25 | |||
26 | u32 read_reg(struct csc_data *csc, int offset) | ||
27 | { | ||
28 | return ioread32(csc->base + offset); | ||
29 | } | ||
30 | |||
31 | #define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, read_reg(csc, CSC_##r)) | ||
32 | |||
33 | DUMPREG(CSC00); | ||
34 | DUMPREG(CSC01); | ||
35 | DUMPREG(CSC02); | ||
36 | DUMPREG(CSC03); | ||
37 | DUMPREG(CSC04); | ||
38 | DUMPREG(CSC05); | ||
39 | |||
40 | #undef DUMPREG | ||
41 | } | ||
42 | |||
43 | void csc_set_coeff_bypass(struct csc_data *csc, u32 *csc_reg5) | ||
44 | { | ||
45 | *csc_reg5 |= CSC_BYPASS; | ||
46 | } | ||
47 | |||
48 | struct csc_data *csc_create(struct platform_device *pdev) | ||
49 | { | ||
50 | struct csc_data *csc; | ||
51 | |||
52 | dev_dbg(&pdev->dev, "csc_create\n"); | ||
53 | |||
54 | csc = devm_kzalloc(&pdev->dev, sizeof(*csc), GFP_KERNEL); | ||
55 | if (!csc) { | ||
56 | dev_err(&pdev->dev, "couldn't alloc csc_data\n"); | ||
57 | return ERR_PTR(-ENOMEM); | ||
58 | } | ||
59 | |||
60 | csc->pdev = pdev; | ||
61 | |||
62 | csc->res = platform_get_resource_byname(pdev, IORESOURCE_MEM, | ||
63 | "vpe_csc"); | ||
64 | if (csc->res == NULL) { | ||
65 | dev_err(&pdev->dev, "missing platform resources data\n"); | ||
66 | return ERR_PTR(-ENODEV); | ||
67 | } | ||
68 | |||
69 | csc->base = devm_ioremap_resource(&pdev->dev, csc->res); | ||
70 | if (!csc->base) { | ||
71 | dev_err(&pdev->dev, "failed to ioremap\n"); | ||
72 | return ERR_PTR(-ENOMEM); | ||
73 | } | ||
74 | |||
75 | return csc; | ||
76 | } | ||
diff --git a/drivers/media/platform/ti-vpe/csc.h b/drivers/media/platform/ti-vpe/csc.h new file mode 100644 index 000000000000..57b5ed600394 --- /dev/null +++ b/drivers/media/platform/ti-vpe/csc.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2013 Texas Instruments Inc. | ||
3 | * | ||
4 | * David Griego, <dagriego@biglakesoftware.com> | ||
5 | * Dale Farnsworth, <dale@farnsworth.org> | ||
6 | * Archit Taneja, <archit@ti.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License version 2 as published by | ||
10 | * the Free Software Foundation. | ||
11 | */ | ||
12 | #ifndef TI_CSC_H | ||
13 | #define TI_CSC_H | ||
14 | |||
15 | /* VPE color space converter regs */ | ||
16 | #define CSC_CSC00 0x00 | ||
17 | #define CSC_A0_MASK 0x1fff | ||
18 | #define CSC_A0_SHIFT 0 | ||
19 | #define CSC_B0_MASK 0x1fff | ||
20 | #define CSC_B0_SHIFT 16 | ||
21 | |||
22 | #define CSC_CSC01 0x04 | ||
23 | #define CSC_C0_MASK 0x1fff | ||
24 | #define CSC_C0_SHIFT 0 | ||
25 | #define CSC_A1_MASK 0x1fff | ||
26 | #define CSC_A1_SHIFT 16 | ||
27 | |||
28 | #define CSC_CSC02 0x08 | ||
29 | #define CSC_B1_MASK 0x1fff | ||
30 | #define CSC_B1_SHIFT 0 | ||
31 | #define CSC_C1_MASK 0x1fff | ||
32 | #define CSC_C1_SHIFT 16 | ||
33 | |||
34 | #define CSC_CSC03 0x0c | ||
35 | #define CSC_A2_MASK 0x1fff | ||
36 | #define CSC_A2_SHIFT 0 | ||
37 | #define CSC_B2_MASK 0x1fff | ||
38 | #define CSC_B2_SHIFT 16 | ||
39 | |||
40 | #define CSC_CSC04 0x10 | ||
41 | #define CSC_C2_MASK 0x1fff | ||
42 | #define CSC_C2_SHIFT 0 | ||
43 | #define CSC_D0_MASK 0x0fff | ||
44 | #define CSC_D0_SHIFT 16 | ||
45 | |||
46 | #define CSC_CSC05 0x14 | ||
47 | #define CSC_D1_MASK 0x0fff | ||
48 | #define CSC_D1_SHIFT 0 | ||
49 | #define CSC_D2_MASK 0x0fff | ||
50 | #define CSC_D2_SHIFT 16 | ||
51 | |||
52 | #define CSC_BYPASS (1 << 28) | ||
53 | |||
54 | struct csc_data { | ||
55 | void __iomem *base; | ||
56 | struct resource *res; | ||
57 | |||
58 | struct platform_device *pdev; | ||
59 | }; | ||
60 | |||
61 | void csc_dump_regs(struct csc_data *csc); | ||
62 | void csc_set_coeff_bypass(struct csc_data *csc, u32 *csc_reg5); | ||
63 | struct csc_data *csc_create(struct platform_device *pdev); | ||
64 | |||
65 | #endif | ||
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c index dc2b94cb2640..6c4db57fc0c9 100644 --- a/drivers/media/platform/ti-vpe/vpe.c +++ b/drivers/media/platform/ti-vpe/vpe.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include "vpdma.h" | 44 | #include "vpdma.h" |
45 | #include "vpe_regs.h" | 45 | #include "vpe_regs.h" |
46 | #include "sc.h" | 46 | #include "sc.h" |
47 | #include "csc.h" | ||
47 | 48 | ||
48 | #define VPE_MODULE_NAME "vpe" | 49 | #define VPE_MODULE_NAME "vpe" |
49 | 50 | ||
@@ -330,6 +331,7 @@ struct vpe_dev { | |||
330 | struct vb2_alloc_ctx *alloc_ctx; | 331 | struct vb2_alloc_ctx *alloc_ctx; |
331 | struct vpdma_data *vpdma; /* vpdma data handle */ | 332 | struct vpdma_data *vpdma; /* vpdma data handle */ |
332 | struct sc_data *sc; /* scaler data handle */ | 333 | struct sc_data *sc; /* scaler data handle */ |
334 | struct csc_data *csc; /* csc data handle */ | ||
333 | }; | 335 | }; |
334 | 336 | ||
335 | /* | 337 | /* |
@@ -475,7 +477,8 @@ static void init_adb_hdrs(struct vpe_ctx *ctx) | |||
475 | GET_OFFSET_TOP(ctx, ctx->dev->sc, CFG_SC8)); | 477 | GET_OFFSET_TOP(ctx, ctx->dev->sc, CFG_SC8)); |
476 | VPE_SET_MMR_ADB_HDR(ctx, sc_hdr17, sc_regs17, | 478 | VPE_SET_MMR_ADB_HDR(ctx, sc_hdr17, sc_regs17, |
477 | GET_OFFSET_TOP(ctx, ctx->dev->sc, CFG_SC17)); | 479 | GET_OFFSET_TOP(ctx, ctx->dev->sc, CFG_SC17)); |
478 | VPE_SET_MMR_ADB_HDR(ctx, csc_hdr, csc_regs, VPE_CSC_CSC00); | 480 | VPE_SET_MMR_ADB_HDR(ctx, csc_hdr, csc_regs, |
481 | GET_OFFSET_TOP(ctx, ctx->dev->csc, CSC_CSC00)); | ||
479 | }; | 482 | }; |
480 | 483 | ||
481 | /* | 484 | /* |
@@ -758,16 +761,6 @@ static void set_dei_shadow_registers(struct vpe_ctx *ctx) | |||
758 | ctx->load_mmrs = true; | 761 | ctx->load_mmrs = true; |
759 | } | 762 | } |
760 | 763 | ||
761 | static void set_csc_coeff_bypass(struct vpe_ctx *ctx) | ||
762 | { | ||
763 | struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr; | ||
764 | u32 *shadow_csc_reg5 = &mmr_adb->csc_regs[5]; | ||
765 | |||
766 | *shadow_csc_reg5 |= VPE_CSC_BYPASS; | ||
767 | |||
768 | ctx->load_mmrs = true; | ||
769 | } | ||
770 | |||
771 | /* | 764 | /* |
772 | * Set the shadow registers whose values are modified when either the | 765 | * Set the shadow registers whose values are modified when either the |
773 | * source or destination format is changed. | 766 | * source or destination format is changed. |
@@ -819,7 +812,8 @@ static int set_srcdst_params(struct vpe_ctx *ctx) | |||
819 | 812 | ||
820 | set_cfg_and_line_modes(ctx); | 813 | set_cfg_and_line_modes(ctx); |
821 | set_dei_regs(ctx); | 814 | set_dei_regs(ctx); |
822 | set_csc_coeff_bypass(ctx); | 815 | |
816 | csc_set_coeff_bypass(ctx->dev->csc, &mmr_adb->csc_regs[5]); | ||
823 | 817 | ||
824 | sc_set_hs_coeffs(ctx->dev->sc, ctx->sc_coeff_h.addr, src_w, dst_w); | 818 | sc_set_hs_coeffs(ctx->dev->sc, ctx->sc_coeff_h.addr, src_w, dst_w); |
825 | sc_set_vs_coeffs(ctx->dev->sc, ctx->sc_coeff_v.addr, src_h, dst_h); | 819 | sc_set_vs_coeffs(ctx->dev->sc, ctx->sc_coeff_v.addr, src_h, dst_h); |
@@ -942,15 +936,10 @@ static void vpe_dump_regs(struct vpe_dev *dev) | |||
942 | DUMPREG(DEI_FMD_STATUS_R0); | 936 | DUMPREG(DEI_FMD_STATUS_R0); |
943 | DUMPREG(DEI_FMD_STATUS_R1); | 937 | DUMPREG(DEI_FMD_STATUS_R1); |
944 | DUMPREG(DEI_FMD_STATUS_R2); | 938 | DUMPREG(DEI_FMD_STATUS_R2); |
945 | DUMPREG(CSC_CSC00); | ||
946 | DUMPREG(CSC_CSC01); | ||
947 | DUMPREG(CSC_CSC02); | ||
948 | DUMPREG(CSC_CSC03); | ||
949 | DUMPREG(CSC_CSC04); | ||
950 | DUMPREG(CSC_CSC05); | ||
951 | #undef DUMPREG | 939 | #undef DUMPREG |
952 | 940 | ||
953 | sc_dump_regs(dev->sc); | 941 | sc_dump_regs(dev->sc); |
942 | csc_dump_regs(dev->csc); | ||
954 | } | 943 | } |
955 | 944 | ||
956 | static void add_out_dtd(struct vpe_ctx *ctx, int port) | 945 | static void add_out_dtd(struct vpe_ctx *ctx, int port) |
@@ -2074,6 +2063,12 @@ static int vpe_probe(struct platform_device *pdev) | |||
2074 | goto runtime_put; | 2063 | goto runtime_put; |
2075 | } | 2064 | } |
2076 | 2065 | ||
2066 | dev->csc = csc_create(pdev); | ||
2067 | if (IS_ERR(dev->csc)) { | ||
2068 | ret = PTR_ERR(dev->csc); | ||
2069 | goto runtime_put; | ||
2070 | } | ||
2071 | |||
2077 | dev->vpdma = vpdma_create(pdev); | 2072 | dev->vpdma = vpdma_create(pdev); |
2078 | if (IS_ERR(dev->vpdma)) { | 2073 | if (IS_ERR(dev->vpdma)) { |
2079 | ret = PTR_ERR(dev->vpdma); | 2074 | ret = PTR_ERR(dev->vpdma); |
diff --git a/drivers/media/platform/ti-vpe/vpe_regs.h b/drivers/media/platform/ti-vpe/vpe_regs.h index d8dbdd375a7d..74283d79eae1 100644 --- a/drivers/media/platform/ti-vpe/vpe_regs.h +++ b/drivers/media/platform/ti-vpe/vpe_regs.h | |||
@@ -306,42 +306,4 @@ | |||
306 | #define VPE_FMD_FRAME_DIFF_MASK 0x000fffff | 306 | #define VPE_FMD_FRAME_DIFF_MASK 0x000fffff |
307 | #define VPE_FMD_FRAME_DIFF_SHIFT 0 | 307 | #define VPE_FMD_FRAME_DIFF_SHIFT 0 |
308 | 308 | ||
309 | /* VPE color space converter regs */ | ||
310 | #define VPE_CSC_CSC00 0x5700 | ||
311 | #define VPE_CSC_A0_MASK 0x1fff | ||
312 | #define VPE_CSC_A0_SHIFT 0 | ||
313 | #define VPE_CSC_B0_MASK 0x1fff | ||
314 | #define VPE_CSC_B0_SHIFT 16 | ||
315 | |||
316 | #define VPE_CSC_CSC01 0x5704 | ||
317 | #define VPE_CSC_C0_MASK 0x1fff | ||
318 | #define VPE_CSC_C0_SHIFT 0 | ||
319 | #define VPE_CSC_A1_MASK 0x1fff | ||
320 | #define VPE_CSC_A1_SHIFT 16 | ||
321 | |||
322 | #define VPE_CSC_CSC02 0x5708 | ||
323 | #define VPE_CSC_B1_MASK 0x1fff | ||
324 | #define VPE_CSC_B1_SHIFT 0 | ||
325 | #define VPE_CSC_C1_MASK 0x1fff | ||
326 | #define VPE_CSC_C1_SHIFT 16 | ||
327 | |||
328 | #define VPE_CSC_CSC03 0x570c | ||
329 | #define VPE_CSC_A2_MASK 0x1fff | ||
330 | #define VPE_CSC_A2_SHIFT 0 | ||
331 | #define VPE_CSC_B2_MASK 0x1fff | ||
332 | #define VPE_CSC_B2_SHIFT 16 | ||
333 | |||
334 | #define VPE_CSC_CSC04 0x5710 | ||
335 | #define VPE_CSC_C2_MASK 0x1fff | ||
336 | #define VPE_CSC_C2_SHIFT 0 | ||
337 | #define VPE_CSC_D0_MASK 0x0fff | ||
338 | #define VPE_CSC_D0_SHIFT 16 | ||
339 | |||
340 | #define VPE_CSC_CSC05 0x5714 | ||
341 | #define VPE_CSC_D1_MASK 0x0fff | ||
342 | #define VPE_CSC_D1_SHIFT 0 | ||
343 | #define VPE_CSC_D2_MASK 0x0fff | ||
344 | #define VPE_CSC_D2_SHIFT 16 | ||
345 | #define VPE_CSC_BYPASS (1 << 28) | ||
346 | |||
347 | #endif | 309 | #endif |