aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/coda
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-03-16 21:27:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-16 21:27:32 -0400
commitbace3db5da970c4d4f80a1ffa988ec66c7f6a8f5 (patch)
treeab893a29048a3a4ae91d7261a8f4946f3017eff1 /drivers/media/platform/coda
parent8759957b77ac1b5b5bdfac5ba049789107e85190 (diff)
parent8331c055b23c4155b896a2c3791704ae68992d2b (diff)
Merge tag 'media/v4.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - Added support for some new video formats - mn88473 DVB frontend driver got promoted from staging - several improvements at the VSP1 driver - several cleanups and improvements at the Media Controller - added Media Controller support to snd-usb-audio. Currently, enabled only for au0828-based V4L2/DVB boards - Several improvements at nuvoton-cir: it now supports wake up codes - Add media controller support to em28xx and saa7134 drivers - coda driver now accepts NXP distributed firmware files - Some legacy SoC camera drivers will be moving to staging, as they're outdated and nobody so far is willing to fix and convert them to use the current media framework - As usual, lots of cleanups, improvements and new board additions. * tag 'media/v4.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (381 commits) media: au0828 disable tuner to demod link in au0828_media_device_register() [media] touptek: cast char types on %x printk [media] touptek: don't DMA at the stack [media] mceusb: use %*ph for small buffer dumps [media] v4l: exynos4-is: Drop unneeded check when setting up fimc-lite links [media] v4l: vsp1: Check if an entity is a subdev with the right function [media] hide unused functions for !MEDIA_CONTROLLER [media] em28xx: fix Terratec Grabby AC97 codec detection [media] media: add prefixes to interface types [media] media: rc: nuvoton: switch attribute wakeup_data to text [media] v4l2-ioctl: fix YUV422P pixel format description [media] media: fix null pointer dereference in v4l_vb2q_enable_media_source() [media] v4l2-mc.h: fix yet more compiler errors [media] staging/media: add missing TODO files [media] media.h: always start with 1 for the audio entities [media] sound/usb: Use meaninful names for goto labels [media] v4l2-mc.h: fix compiler warnings [media] media: au0828 audio mixer isn't connected to decoder [media] sound/usb: Use Media Controller API to share media resources [media] dw2102: add support for TeVii S662 ...
Diffstat (limited to 'drivers/media/platform/coda')
-rw-r--r--drivers/media/platform/coda/coda-bit.c2
-rw-r--r--drivers/media/platform/coda/coda-common.c106
-rw-r--r--drivers/media/platform/coda/coda.h3
3 files changed, 85 insertions, 26 deletions
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 38aacc7fc692..b6625047250d 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1342,7 +1342,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)
1342 1342
1343 /* Calculate bytesused field */ 1343 /* Calculate bytesused field */
1344 if (dst_buf->sequence == 0) { 1344 if (dst_buf->sequence == 0) {
1345 vb2_set_plane_payload(&dst_buf->vb2_buf, 0, 1345 vb2_set_plane_payload(&dst_buf->vb2_buf, 0, wr_ptr - start_ptr +
1346 ctx->vpu_header_size[0] + 1346 ctx->vpu_header_size[0] +
1347 ctx->vpu_header_size[1] + 1347 ctx->vpu_header_size[1] +
1348 ctx->vpu_header_size[2]); 1348 ctx->vpu_header_size[2]);
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 2d782ce94a67..133ab9f70f85 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1950,16 +1950,76 @@ static int coda_register_device(struct coda_dev *dev, int i)
1950 return video_register_device(vfd, VFL_TYPE_GRABBER, 0); 1950 return video_register_device(vfd, VFL_TYPE_GRABBER, 0);
1951} 1951}
1952 1952
1953static void coda_copy_firmware(struct coda_dev *dev, const u8 * const buf,
1954 size_t size)
1955{
1956 u32 *src = (u32 *)buf;
1957
1958 /* Check if the firmware has a 16-byte Freescale header, skip it */
1959 if (buf[0] == 'M' && buf[1] == 'X')
1960 src += 4;
1961 /*
1962 * Check whether the firmware is in native order or pre-reordered for
1963 * memory access. The first instruction opcode always is 0xe40e.
1964 */
1965 if (__le16_to_cpup((__le16 *)src) == 0xe40e) {
1966 u32 *dst = dev->codebuf.vaddr;
1967 int i;
1968
1969 /* Firmware in native order, reorder while copying */
1970 if (dev->devtype->product == CODA_DX6) {
1971 for (i = 0; i < (size - 16) / 4; i++)
1972 dst[i] = (src[i] << 16) | (src[i] >> 16);
1973 } else {
1974 for (i = 0; i < (size - 16) / 4; i += 2) {
1975 dst[i] = (src[i + 1] << 16) | (src[i + 1] >> 16);
1976 dst[i + 1] = (src[i] << 16) | (src[i] >> 16);
1977 }
1978 }
1979 } else {
1980 /* Copy the already reordered firmware image */
1981 memcpy(dev->codebuf.vaddr, src, size);
1982 }
1983}
1984
1985static void coda_fw_callback(const struct firmware *fw, void *context);
1986
1987static int coda_firmware_request(struct coda_dev *dev)
1988{
1989 char *fw = dev->devtype->firmware[dev->firmware];
1990
1991 dev_dbg(&dev->plat_dev->dev, "requesting firmware '%s' for %s\n", fw,
1992 coda_product_name(dev->devtype->product));
1993
1994 return request_firmware_nowait(THIS_MODULE, true, fw,
1995 &dev->plat_dev->dev, GFP_KERNEL, dev,
1996 coda_fw_callback);
1997}
1998
1953static void coda_fw_callback(const struct firmware *fw, void *context) 1999static void coda_fw_callback(const struct firmware *fw, void *context)
1954{ 2000{
1955 struct coda_dev *dev = context; 2001 struct coda_dev *dev = context;
1956 struct platform_device *pdev = dev->plat_dev; 2002 struct platform_device *pdev = dev->plat_dev;
1957 int i, ret; 2003 int i, ret;
1958 2004
1959 if (!fw) { 2005 if (!fw && dev->firmware == 1) {
1960 v4l2_err(&dev->v4l2_dev, "firmware request failed\n"); 2006 v4l2_err(&dev->v4l2_dev, "firmware request failed\n");
1961 goto put_pm; 2007 goto put_pm;
1962 } 2008 }
2009 if (!fw) {
2010 dev->firmware = 1;
2011 coda_firmware_request(dev);
2012 return;
2013 }
2014 if (dev->firmware == 1) {
2015 /*
2016 * Since we can't suppress warnings for failed asynchronous
2017 * firmware requests, report that the fallback firmware was
2018 * found.
2019 */
2020 dev_info(&pdev->dev, "Using fallback firmware %s\n",
2021 dev->devtype->firmware[dev->firmware]);
2022 }
1963 2023
1964 /* allocate auxiliary per-device code buffer for the BIT processor */ 2024 /* allocate auxiliary per-device code buffer for the BIT processor */
1965 ret = coda_alloc_aux_buf(dev, &dev->codebuf, fw->size, "codebuf", 2025 ret = coda_alloc_aux_buf(dev, &dev->codebuf, fw->size, "codebuf",
@@ -1967,8 +2027,7 @@ static void coda_fw_callback(const struct firmware *fw, void *context)
1967 if (ret < 0) 2027 if (ret < 0)
1968 goto put_pm; 2028 goto put_pm;
1969 2029
1970 /* Copy the whole firmware image to the code buffer */ 2030 coda_copy_firmware(dev, fw->data, fw->size);
1971 memcpy(dev->codebuf.vaddr, fw->data, fw->size);
1972 release_firmware(fw); 2031 release_firmware(fw);
1973 2032
1974 ret = coda_hw_init(dev); 2033 ret = coda_hw_init(dev);
@@ -2019,17 +2078,6 @@ put_pm:
2019 pm_runtime_put_sync(&pdev->dev); 2078 pm_runtime_put_sync(&pdev->dev);
2020} 2079}
2021 2080
2022static int coda_firmware_request(struct coda_dev *dev)
2023{
2024 char *fw = dev->devtype->firmware;
2025
2026 dev_dbg(&dev->plat_dev->dev, "requesting firmware '%s' for %s\n", fw,
2027 coda_product_name(dev->devtype->product));
2028
2029 return request_firmware_nowait(THIS_MODULE, true,
2030 fw, &dev->plat_dev->dev, GFP_KERNEL, dev, coda_fw_callback);
2031}
2032
2033enum coda_platform { 2081enum coda_platform {
2034 CODA_IMX27, 2082 CODA_IMX27,
2035 CODA_IMX53, 2083 CODA_IMX53,
@@ -2039,7 +2087,10 @@ enum coda_platform {
2039 2087
2040static const struct coda_devtype coda_devdata[] = { 2088static const struct coda_devtype coda_devdata[] = {
2041 [CODA_IMX27] = { 2089 [CODA_IMX27] = {
2042 .firmware = "v4l-codadx6-imx27.bin", 2090 .firmware = {
2091 "vpu_fw_imx27_TO2.bin",
2092 "v4l-codadx6-imx27.bin"
2093 },
2043 .product = CODA_DX6, 2094 .product = CODA_DX6,
2044 .codecs = codadx6_codecs, 2095 .codecs = codadx6_codecs,
2045 .num_codecs = ARRAY_SIZE(codadx6_codecs), 2096 .num_codecs = ARRAY_SIZE(codadx6_codecs),
@@ -2049,7 +2100,10 @@ static const struct coda_devtype coda_devdata[] = {
2049 .iram_size = 0xb000, 2100 .iram_size = 0xb000,
2050 }, 2101 },
2051 [CODA_IMX53] = { 2102 [CODA_IMX53] = {
2052 .firmware = "v4l-coda7541-imx53.bin", 2103 .firmware = {
2104 "vpu_fw_imx53.bin",
2105 "v4l-coda7541-imx53.bin"
2106 },
2053 .product = CODA_7541, 2107 .product = CODA_7541,
2054 .codecs = coda7_codecs, 2108 .codecs = coda7_codecs,
2055 .num_codecs = ARRAY_SIZE(coda7_codecs), 2109 .num_codecs = ARRAY_SIZE(coda7_codecs),
@@ -2060,7 +2114,10 @@ static const struct coda_devtype coda_devdata[] = {
2060 .iram_size = 0x14000, 2114 .iram_size = 0x14000,
2061 }, 2115 },
2062 [CODA_IMX6Q] = { 2116 [CODA_IMX6Q] = {
2063 .firmware = "v4l-coda960-imx6q.bin", 2117 .firmware = {
2118 "vpu_fw_imx6q.bin",
2119 "v4l-coda960-imx6q.bin"
2120 },
2064 .product = CODA_960, 2121 .product = CODA_960,
2065 .codecs = coda9_codecs, 2122 .codecs = coda9_codecs,
2066 .num_codecs = ARRAY_SIZE(coda9_codecs), 2123 .num_codecs = ARRAY_SIZE(coda9_codecs),
@@ -2071,7 +2128,10 @@ static const struct coda_devtype coda_devdata[] = {
2071 .iram_size = 0x21000, 2128 .iram_size = 0x21000,
2072 }, 2129 },
2073 [CODA_IMX6DL] = { 2130 [CODA_IMX6DL] = {
2074 .firmware = "v4l-coda960-imx6dl.bin", 2131 .firmware = {
2132 "vpu_fw_imx6d.bin",
2133 "v4l-coda960-imx6dl.bin"
2134 },
2075 .product = CODA_960, 2135 .product = CODA_960,
2076 .codecs = coda9_codecs, 2136 .codecs = coda9_codecs,
2077 .num_codecs = ARRAY_SIZE(coda9_codecs), 2137 .num_codecs = ARRAY_SIZE(coda9_codecs),
@@ -2118,14 +2178,12 @@ static int coda_probe(struct platform_device *pdev)
2118 2178
2119 pdev_id = of_id ? of_id->data : platform_get_device_id(pdev); 2179 pdev_id = of_id ? of_id->data : platform_get_device_id(pdev);
2120 2180
2121 if (of_id) { 2181 if (of_id)
2122 dev->devtype = of_id->data; 2182 dev->devtype = of_id->data;
2123 } else if (pdev_id) { 2183 else if (pdev_id)
2124 dev->devtype = &coda_devdata[pdev_id->driver_data]; 2184 dev->devtype = &coda_devdata[pdev_id->driver_data];
2125 } else { 2185 else
2126 ret = -EINVAL; 2186 return -EINVAL;
2127 goto err_v4l2_register;
2128 }
2129 2187
2130 spin_lock_init(&dev->irqlock); 2188 spin_lock_init(&dev->irqlock);
2131 INIT_LIST_HEAD(&dev->instances); 2189 INIT_LIST_HEAD(&dev->instances);
diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h
index d08e9843e9f2..8f2c71e06966 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -50,7 +50,7 @@ enum coda_product {
50struct coda_video_device; 50struct coda_video_device;
51 51
52struct coda_devtype { 52struct coda_devtype {
53 char *firmware; 53 char *firmware[2];
54 enum coda_product product; 54 enum coda_product product;
55 const struct coda_codec *codecs; 55 const struct coda_codec *codecs;
56 unsigned int num_codecs; 56 unsigned int num_codecs;
@@ -74,6 +74,7 @@ struct coda_dev {
74 struct video_device vfd[5]; 74 struct video_device vfd[5];
75 struct platform_device *plat_dev; 75 struct platform_device *plat_dev;
76 const struct coda_devtype *devtype; 76 const struct coda_devtype *devtype;
77 int firmware;
77 78
78 void __iomem *regs_base; 79 void __iomem *regs_base;
79 struct clk *clk_per; 80 struct clk *clk_per;