Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: coda: use genalloc API

This patch depends on "genalloc: add devres support, allow to find a
managed pool by device", which provides the of_get_named_gen_pool and
dev_get_gen_pool functions.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Javier Martin <javier.martin@vista-silicon.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Dong Aisheng <dong.aisheng@linaro.org>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Huang Shijie <shijie8@gmail.com>
Cc: Matt Porter <mporter@ti.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Philipp Zabel and committed by
Linus Torvalds
657eee7d 4984c6f5

+79 -15
+30
Documentation/devicetree/bindings/media/coda.txt
··· 1 + Chips&Media Coda multi-standard codec IP 2 + ======================================== 3 + 4 + Coda codec IPs are present in i.MX SoCs in various versions, 5 + called VPU (Video Processing Unit). 6 + 7 + Required properties: 8 + - compatible : should be "fsl,<chip>-src" for i.MX SoCs: 9 + (a) "fsl,imx27-vpu" for CodaDx6 present in i.MX27 10 + (b) "fsl,imx53-vpu" for CODA7541 present in i.MX53 11 + (c) "fsl,imx6q-vpu" for CODA960 present in i.MX6q 12 + - reg: should be register base and length as documented in the 13 + SoC reference manual 14 + - interrupts : Should contain the VPU interrupt. For CODA960, 15 + a second interrupt is needed for the MJPEG unit. 16 + - clocks : Should contain the ahb and per clocks, in the order 17 + determined by the clock-names property. 18 + - clock-names : Should be "ahb", "per" 19 + - iram : phandle pointing to the SRAM device node 20 + 21 + Example: 22 + 23 + vpu: vpu@63ff4000 { 24 + compatible = "fsl,imx53-vpu"; 25 + reg = <0x63ff4000 0x1000>; 26 + interrupts = <9>; 27 + clocks = <&clks 63>, <&clks 63>; 28 + clock-names = "ahb", "per"; 29 + iram = <&ocram>; 30 + };
-1
drivers/media/platform/Kconfig
··· 145 145 depends on VIDEO_DEV && VIDEO_V4L2 && ARCH_MXC 146 146 select VIDEOBUF2_DMA_CONTIG 147 147 select V4L2_MEM2MEM_DEV 148 - select IRAM_ALLOC if SOC_IMX53 149 148 ---help--- 150 149 Coda is a range of video codec IPs that supports 151 150 H.264, MPEG-4, and other video formats.
+31 -14
drivers/media/platform/coda.c
··· 14 14 #include <linux/clk.h> 15 15 #include <linux/delay.h> 16 16 #include <linux/firmware.h> 17 + #include <linux/genalloc.h> 17 18 #include <linux/interrupt.h> 18 19 #include <linux/io.h> 19 20 #include <linux/irq.h> ··· 24 23 #include <linux/slab.h> 25 24 #include <linux/videodev2.h> 26 25 #include <linux/of.h> 27 - #include <linux/platform_data/imx-iram.h> 26 + #include <linux/platform_data/coda.h> 28 27 29 28 #include <media/v4l2-ctrls.h> 30 29 #include <media/v4l2-device.h> ··· 44 43 #define CODA7_WORK_BUF_SIZE (512 * 1024 + CODA_FMO_BUF_SIZE * 8 * 1024) 45 44 #define CODA_PARA_BUF_SIZE (10 * 1024) 46 45 #define CODA_ISRAM_SIZE (2048 * 2) 46 + #define CODADX6_IRAM_SIZE 0xb000 47 47 #define CODA7_IRAM_SIZE 0x14000 /* 81920 bytes */ 48 48 49 49 #define CODA_MAX_FRAMEBUFFERS 2 ··· 130 128 131 129 struct coda_aux_buf codebuf; 132 130 struct coda_aux_buf workbuf; 131 + struct gen_pool *iram_pool; 132 + long unsigned int iram_vaddr; 133 133 long unsigned int iram_paddr; 134 + unsigned long iram_size; 134 135 135 136 spinlock_t irqlock; 136 137 struct mutex dev_mutex; ··· 1931 1926 const struct of_device_id *of_id = 1932 1927 of_match_device(of_match_ptr(coda_dt_ids), &pdev->dev); 1933 1928 const struct platform_device_id *pdev_id; 1929 + struct coda_platform_data *pdata = pdev->dev.platform_data; 1930 + struct device_node *np = pdev->dev.of_node; 1931 + struct gen_pool *pool; 1934 1932 struct coda_dev *dev; 1935 1933 struct resource *res; 1936 1934 int ret, irq; ··· 1996 1988 return -ENOENT; 1997 1989 } 1998 1990 1991 + /* Get IRAM pool from device tree or platform data */ 1992 + pool = of_get_named_gen_pool(np, "iram", 0); 1993 + if (!pool && pdata) 1994 + pool = dev_get_gen_pool(pdata->iram_dev); 1995 + if (!pool) { 1996 + dev_err(&pdev->dev, "iram pool not available\n"); 1997 + return -ENOMEM; 1998 + } 1999 + dev->iram_pool = pool; 2000 + 1999 2001 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); 2000 2002 if (ret) 2001 2003 return ret; ··· 2040 2022 return -ENOMEM; 2041 2023 } 2042 2024 2043 - if (dev->devtype->product == CODA_DX6) { 2044 - dev->iram_paddr = 0xffff4c00; 2045 - } else { 2046 - void __iomem *iram_vaddr; 2047 - 2048 - iram_vaddr = iram_alloc(CODA7_IRAM_SIZE, 2049 - &dev->iram_paddr); 2050 - if (!iram_vaddr) { 2051 - dev_err(&pdev->dev, "unable to alloc iram\n"); 2052 - return -ENOMEM; 2053 - } 2025 + if (dev->devtype->product == CODA_DX6) 2026 + dev->iram_size = CODADX6_IRAM_SIZE; 2027 + else 2028 + dev->iram_size = CODA7_IRAM_SIZE; 2029 + dev->iram_vaddr = gen_pool_alloc(dev->iram_pool, dev->iram_size); 2030 + if (!dev->iram_vaddr) { 2031 + dev_err(&pdev->dev, "unable to alloc iram\n"); 2032 + return -ENOMEM; 2054 2033 } 2034 + dev->iram_paddr = gen_pool_virt_to_phys(dev->iram_pool, 2035 + dev->iram_vaddr); 2055 2036 2056 2037 platform_set_drvdata(pdev, dev); 2057 2038 ··· 2067 2050 if (dev->alloc_ctx) 2068 2051 vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); 2069 2052 v4l2_device_unregister(&dev->v4l2_dev); 2070 - if (dev->iram_paddr) 2071 - iram_free(dev->iram_paddr, CODA7_IRAM_SIZE); 2053 + if (dev->iram_vaddr) 2054 + gen_pool_free(dev->iram_pool, dev->iram_vaddr, dev->iram_size); 2072 2055 if (dev->codebuf.vaddr) 2073 2056 dma_free_coherent(&pdev->dev, dev->codebuf.size, 2074 2057 &dev->codebuf.vaddr, dev->codebuf.paddr);
+18
include/linux/platform_data/coda.h
··· 1 + /* 2 + * Copyright (C) 2013 Philipp Zabel, Pengutronix 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License as published by 6 + * the Free Software Foundation; either version 2 of the License, or 7 + * (at your option) any later version. 8 + */ 9 + #ifndef PLATFORM_CODA_H 10 + #define PLATFORM_CODA_H 11 + 12 + struct device; 13 + 14 + struct coda_platform_data { 15 + struct device *iram_dev; 16 + }; 17 + 18 + #endif