Commit 2ac7f08e authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

[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: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent b5a442aa
...@@ -1982,16 +1982,44 @@ static void coda_copy_firmware(struct coda_dev *dev, const u8 * const buf, ...@@ -1982,16 +1982,44 @@ static void coda_copy_firmware(struct coda_dev *dev, const u8 * const buf,
} }
} }
static void coda_fw_callback(const struct firmware *fw, void *context);
static int coda_firmware_request(struct coda_dev *dev)
{
char *fw = dev->devtype->firmware[dev->firmware];
dev_dbg(&dev->plat_dev->dev, "requesting firmware '%s' for %s\n", fw,
coda_product_name(dev->devtype->product));
return request_firmware_nowait(THIS_MODULE, true, fw,
&dev->plat_dev->dev, GFP_KERNEL, dev,
coda_fw_callback);
}
static void coda_fw_callback(const struct firmware *fw, void *context) static void coda_fw_callback(const struct firmware *fw, void *context)
{ {
struct coda_dev *dev = context; struct coda_dev *dev = context;
struct platform_device *pdev = dev->plat_dev; struct platform_device *pdev = dev->plat_dev;
int i, ret; int i, ret;
if (!fw) { if (!fw && dev->firmware == 1) {
v4l2_err(&dev->v4l2_dev, "firmware request failed\n"); v4l2_err(&dev->v4l2_dev, "firmware request failed\n");
goto put_pm; goto put_pm;
} }
if (!fw) {
dev->firmware = 1;
coda_firmware_request(dev);
return;
}
if (dev->firmware == 1) {
/*
* Since we can't suppress warnings for failed asynchronous
* firmware requests, report that the fallback firmware was
* found.
*/
dev_info(&pdev->dev, "Using fallback firmware %s\n",
dev->devtype->firmware[dev->firmware]);
}
/* allocate auxiliary per-device code buffer for the BIT processor */ /* allocate auxiliary per-device code buffer for the BIT processor */
ret = coda_alloc_aux_buf(dev, &dev->codebuf, fw->size, "codebuf", ret = coda_alloc_aux_buf(dev, &dev->codebuf, fw->size, "codebuf",
...@@ -2050,17 +2078,6 @@ static void coda_fw_callback(const struct firmware *fw, void *context) ...@@ -2050,17 +2078,6 @@ static void coda_fw_callback(const struct firmware *fw, void *context)
pm_runtime_put_sync(&pdev->dev); pm_runtime_put_sync(&pdev->dev);
} }
static int coda_firmware_request(struct coda_dev *dev)
{
char *fw = dev->devtype->firmware;
dev_dbg(&dev->plat_dev->dev, "requesting firmware '%s' for %s\n", fw,
coda_product_name(dev->devtype->product));
return request_firmware_nowait(THIS_MODULE, true,
fw, &dev->plat_dev->dev, GFP_KERNEL, dev, coda_fw_callback);
}
enum coda_platform { enum coda_platform {
CODA_IMX27, CODA_IMX27,
CODA_IMX53, CODA_IMX53,
...@@ -2070,7 +2087,10 @@ enum coda_platform { ...@@ -2070,7 +2087,10 @@ enum coda_platform {
static const struct coda_devtype coda_devdata[] = { static const struct coda_devtype coda_devdata[] = {
[CODA_IMX27] = { [CODA_IMX27] = {
.firmware = "v4l-codadx6-imx27.bin", .firmware = {
"vpu_fw_imx27_TO2.bin",
"v4l-codadx6-imx27.bin"
},
.product = CODA_DX6, .product = CODA_DX6,
.codecs = codadx6_codecs, .codecs = codadx6_codecs,
.num_codecs = ARRAY_SIZE(codadx6_codecs), .num_codecs = ARRAY_SIZE(codadx6_codecs),
...@@ -2080,7 +2100,10 @@ static const struct coda_devtype coda_devdata[] = { ...@@ -2080,7 +2100,10 @@ static const struct coda_devtype coda_devdata[] = {
.iram_size = 0xb000, .iram_size = 0xb000,
}, },
[CODA_IMX53] = { [CODA_IMX53] = {
.firmware = "v4l-coda7541-imx53.bin", .firmware = {
"vpu_fw_imx53.bin",
"v4l-coda7541-imx53.bin"
},
.product = CODA_7541, .product = CODA_7541,
.codecs = coda7_codecs, .codecs = coda7_codecs,
.num_codecs = ARRAY_SIZE(coda7_codecs), .num_codecs = ARRAY_SIZE(coda7_codecs),
...@@ -2091,7 +2114,10 @@ static const struct coda_devtype coda_devdata[] = { ...@@ -2091,7 +2114,10 @@ static const struct coda_devtype coda_devdata[] = {
.iram_size = 0x14000, .iram_size = 0x14000,
}, },
[CODA_IMX6Q] = { [CODA_IMX6Q] = {
.firmware = "v4l-coda960-imx6q.bin", .firmware = {
"vpu_fw_imx6q.bin",
"v4l-coda960-imx6q.bin"
},
.product = CODA_960, .product = CODA_960,
.codecs = coda9_codecs, .codecs = coda9_codecs,
.num_codecs = ARRAY_SIZE(coda9_codecs), .num_codecs = ARRAY_SIZE(coda9_codecs),
...@@ -2102,7 +2128,10 @@ static const struct coda_devtype coda_devdata[] = { ...@@ -2102,7 +2128,10 @@ static const struct coda_devtype coda_devdata[] = {
.iram_size = 0x21000, .iram_size = 0x21000,
}, },
[CODA_IMX6DL] = { [CODA_IMX6DL] = {
.firmware = "v4l-coda960-imx6dl.bin", .firmware = {
"vpu_fw_imx6d.bin",
"v4l-coda960-imx6dl.bin"
},
.product = CODA_960, .product = CODA_960,
.codecs = coda9_codecs, .codecs = coda9_codecs,
.num_codecs = ARRAY_SIZE(coda9_codecs), .num_codecs = ARRAY_SIZE(coda9_codecs),
......
...@@ -50,7 +50,7 @@ enum coda_product { ...@@ -50,7 +50,7 @@ enum coda_product {
struct coda_video_device; struct coda_video_device;
struct coda_devtype { struct coda_devtype {
char *firmware; char *firmware[2];
enum coda_product product; enum coda_product product;
const struct coda_codec *codecs; const struct coda_codec *codecs;
unsigned int num_codecs; unsigned int num_codecs;
...@@ -74,6 +74,7 @@ struct coda_dev { ...@@ -74,6 +74,7 @@ struct coda_dev {
struct video_device vfd[5]; struct video_device vfd[5];
struct platform_device *plat_dev; struct platform_device *plat_dev;
const struct coda_devtype *devtype; const struct coda_devtype *devtype;
int firmware;
void __iomem *regs_base; void __iomem *regs_base;
struct clk *clk_per; struct clk *clk_per;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment