aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2016-02-19 04:18:57 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-03-03 05:33:26 -0500
commit2ac7f08e307509703259bc7352f4dc22bb30ad65 (patch)
treebaebeee3c072ad4475508d6971f6fb9aef0380ca
parentb5a442aab4878489455520980d578ce665033465 (diff)
[media] coda: add support for firmware files named as distributed by NXP
Try loading the firmware from firmware files named vpu_fw_imx*.bin, as they are originally distributed by NXP. Fall back to v4l-coda*-imx6*.bin. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/platform/coda/coda-common.c61
-rw-r--r--drivers/media/platform/coda/coda.h3
2 files changed, 47 insertions, 17 deletions
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 0bc544d578e9..fe884c1eeb82 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1982,16 +1982,44 @@ static void coda_copy_firmware(struct coda_dev *dev, const u8 * const buf,
1982 } 1982 }
1983} 1983}
1984 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
1985static void coda_fw_callback(const struct firmware *fw, void *context) 1999static void coda_fw_callback(const struct firmware *fw, void *context)
1986{ 2000{
1987 struct coda_dev *dev = context; 2001 struct coda_dev *dev = context;
1988 struct platform_device *pdev = dev->plat_dev; 2002 struct platform_device *pdev = dev->plat_dev;
1989 int i, ret; 2003 int i, ret;
1990 2004
1991 if (!fw) { 2005 if (!fw && dev->firmware == 1) {
1992 v4l2_err(&dev->v4l2_dev, "firmware request failed\n"); 2006 v4l2_err(&dev->v4l2_dev, "firmware request failed\n");
1993 goto put_pm; 2007 goto put_pm;
1994 } 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 }
1995 2023
1996 /* allocate auxiliary per-device code buffer for the BIT processor */ 2024 /* allocate auxiliary per-device code buffer for the BIT processor */
1997 ret = coda_alloc_aux_buf(dev, &dev->codebuf, fw->size, "codebuf", 2025 ret = coda_alloc_aux_buf(dev, &dev->codebuf, fw->size, "codebuf",
@@ -2050,17 +2078,6 @@ put_pm:
2050 pm_runtime_put_sync(&pdev->dev); 2078 pm_runtime_put_sync(&pdev->dev);
2051} 2079}
2052 2080
2053static int coda_firmware_request(struct coda_dev *dev)
2054{
2055 char *fw = dev->devtype->firmware;
2056
2057 dev_dbg(&dev->plat_dev->dev, "requesting firmware '%s' for %s\n", fw,
2058 coda_product_name(dev->devtype->product));
2059
2060 return request_firmware_nowait(THIS_MODULE, true,
2061 fw, &dev->plat_dev->dev, GFP_KERNEL, dev, coda_fw_callback);
2062}
2063
2064enum coda_platform { 2081enum coda_platform {
2065 CODA_IMX27, 2082 CODA_IMX27,
2066 CODA_IMX53, 2083 CODA_IMX53,
@@ -2070,7 +2087,10 @@ enum coda_platform {
2070 2087
2071static const struct coda_devtype coda_devdata[] = { 2088static const struct coda_devtype coda_devdata[] = {
2072 [CODA_IMX27] = { 2089 [CODA_IMX27] = {
2073 .firmware = "v4l-codadx6-imx27.bin", 2090 .firmware = {
2091 "vpu_fw_imx27_TO2.bin",
2092 "v4l-codadx6-imx27.bin"
2093 },
2074 .product = CODA_DX6, 2094 .product = CODA_DX6,
2075 .codecs = codadx6_codecs, 2095 .codecs = codadx6_codecs,
2076 .num_codecs = ARRAY_SIZE(codadx6_codecs), 2096 .num_codecs = ARRAY_SIZE(codadx6_codecs),
@@ -2080,7 +2100,10 @@ static const struct coda_devtype coda_devdata[] = {
2080 .iram_size = 0xb000, 2100 .iram_size = 0xb000,
2081 }, 2101 },
2082 [CODA_IMX53] = { 2102 [CODA_IMX53] = {
2083 .firmware = "v4l-coda7541-imx53.bin", 2103 .firmware = {
2104 "vpu_fw_imx53.bin",
2105 "v4l-coda7541-imx53.bin"
2106 },
2084 .product = CODA_7541, 2107 .product = CODA_7541,
2085 .codecs = coda7_codecs, 2108 .codecs = coda7_codecs,
2086 .num_codecs = ARRAY_SIZE(coda7_codecs), 2109 .num_codecs = ARRAY_SIZE(coda7_codecs),
@@ -2091,7 +2114,10 @@ static const struct coda_devtype coda_devdata[] = {
2091 .iram_size = 0x14000, 2114 .iram_size = 0x14000,
2092 }, 2115 },
2093 [CODA_IMX6Q] = { 2116 [CODA_IMX6Q] = {
2094 .firmware = "v4l-coda960-imx6q.bin", 2117 .firmware = {
2118 "vpu_fw_imx6q.bin",
2119 "v4l-coda960-imx6q.bin"
2120 },
2095 .product = CODA_960, 2121 .product = CODA_960,
2096 .codecs = coda9_codecs, 2122 .codecs = coda9_codecs,
2097 .num_codecs = ARRAY_SIZE(coda9_codecs), 2123 .num_codecs = ARRAY_SIZE(coda9_codecs),
@@ -2102,7 +2128,10 @@ static const struct coda_devtype coda_devdata[] = {
2102 .iram_size = 0x21000, 2128 .iram_size = 0x21000,
2103 }, 2129 },
2104 [CODA_IMX6DL] = { 2130 [CODA_IMX6DL] = {
2105 .firmware = "v4l-coda960-imx6dl.bin", 2131 .firmware = {
2132 "vpu_fw_imx6d.bin",
2133 "v4l-coda960-imx6dl.bin"
2134 },
2106 .product = CODA_960, 2135 .product = CODA_960,
2107 .codecs = coda9_codecs, 2136 .codecs = coda9_codecs,
2108 .num_codecs = ARRAY_SIZE(coda9_codecs), 2137 .num_codecs = ARRAY_SIZE(coda9_codecs),
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;