summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2017-02-08 10:48:54 -0200
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-04-05 15:53:06 -0300
commitba5d4563c2b8396c6eaa5545aed2b9237201114e (patch)
treee3f6f04dc175499374a620029c230e9084e551c4
parentba2e161f2834087755f93bc2d66cea1ed9d3fc23 (diff)
downloadop-kernel-dev-ba5d4563c2b8396c6eaa5545aed2b9237201114e.zip
op-kernel-dev-ba5d4563c2b8396c6eaa5545aed2b9237201114e.tar.gz
[media] s5p-mfc: Put firmware to private buffer structure
Use s5p_mfc_priv_buf structure for keeping the firmware image. This will help handling of firmware buffer allocation in the next patches. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com> Tested-by: Javier Martinez Canillas <javier@osg.samsung.com> Acked-by: Andrzej Hajda <a.hajda@samsung.com> Tested-by: Smitha T Murthy <smitha.t@samsung.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_common.h3
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c36
3 files changed, 20 insertions, 21 deletions
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c
index 8c4739c..4c80bb4 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c
@@ -47,7 +47,7 @@ static int s5p_mfc_sys_init_cmd_v5(struct s5p_mfc_dev *dev)
struct s5p_mfc_cmd_args h2r_args;
memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
- h2r_args.arg[0] = dev->fw_size;
+ h2r_args.arg[0] = dev->fw_buf.size;
return s5p_mfc_cmd_host2risc_v5(dev, S5P_FIMV_H2R_CMD_SYS_INIT,
&h2r_args);
}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 9cf860f..cea17a7 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -314,8 +314,7 @@ struct s5p_mfc_dev {
int int_type;
unsigned int int_err;
wait_queue_head_t queue;
- size_t fw_size;
- void *fw_virt_addr;
+ struct s5p_mfc_priv_buf fw_buf;
dma_addr_t dma_base[BANK_CTX_NUM];
unsigned long hw_lock;
struct s5p_mfc_ctx *ctx[MFC_NUM_CONTEXTS];
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index c9bff3d..50d6989 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -29,21 +29,22 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev)
void *bank2_virt;
dma_addr_t bank2_dma_addr;
unsigned int align_size = 1 << MFC_BASE_ALIGN_ORDER;
+ struct s5p_mfc_priv_buf *fw_buf = &dev->fw_buf;
- dev->fw_size = dev->variant->buf_size->fw;
+ fw_buf->size = dev->variant->buf_size->fw;
- if (dev->fw_virt_addr) {
+ if (fw_buf->virt) {
mfc_err("Attempting to allocate firmware when it seems that it is already loaded\n");
return -ENOMEM;
}
- dev->fw_virt_addr = dma_alloc_coherent(dev->mem_dev[BANK1_CTX],
- dev->fw_size, &dev->dma_base[BANK1_CTX],
- GFP_KERNEL);
- if (!dev->fw_virt_addr) {
+ fw_buf->virt = dma_alloc_coherent(dev->mem_dev[BANK1_CTX], fw_buf->size,
+ &fw_buf->dma, GFP_KERNEL);
+ if (!fw_buf->virt) {
mfc_err("Allocating bitprocessor buffer failed\n");
return -ENOMEM;
}
+ dev->dma_base[BANK1_CTX] = fw_buf->dma;
if (HAS_PORTNUM(dev) && IS_TWOPORT(dev)) {
bank2_virt = dma_alloc_coherent(dev->mem_dev[BANK2_CTX],
@@ -51,10 +52,9 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev)
if (!bank2_virt) {
mfc_err("Allocating bank2 base failed\n");
- dma_free_coherent(dev->mem_dev[BANK1_CTX], dev->fw_size,
- dev->fw_virt_addr,
- dev->dma_base[BANK1_CTX]);
- dev->fw_virt_addr = NULL;
+ dma_free_coherent(dev->mem_dev[BANK1_CTX], fw_buf->size,
+ fw_buf->virt, fw_buf->dma);
+ fw_buf->virt = NULL;
return -ENOMEM;
}
@@ -101,17 +101,17 @@ int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev)
mfc_err("Firmware is not present in the /lib/firmware directory nor compiled in kernel\n");
return -EINVAL;
}
- if (fw_blob->size > dev->fw_size) {
+ if (fw_blob->size > dev->fw_buf.size) {
mfc_err("MFC firmware is too big to be loaded\n");
release_firmware(fw_blob);
return -ENOMEM;
}
- if (!dev->fw_virt_addr) {
+ if (!dev->fw_buf.virt) {
mfc_err("MFC firmware is not allocated\n");
release_firmware(fw_blob);
return -EINVAL;
}
- memcpy(dev->fw_virt_addr, fw_blob->data, fw_blob->size);
+ memcpy(dev->fw_buf.virt, fw_blob->data, fw_blob->size);
wmb();
release_firmware(fw_blob);
mfc_debug_leave();
@@ -123,11 +123,11 @@ int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev)
{
/* Before calling this function one has to make sure
* that MFC is no longer processing */
- if (!dev->fw_virt_addr)
+ if (!dev->fw_buf.virt)
return -EINVAL;
- dma_free_coherent(dev->mem_dev[BANK1_CTX], dev->fw_size,
- dev->fw_virt_addr, dev->dma_base[BANK1_CTX]);
- dev->fw_virt_addr = NULL;
+ dma_free_coherent(dev->mem_dev[BANK1_CTX], dev->fw_buf.size,
+ dev->fw_buf.virt, dev->fw_buf.dma);
+ dev->fw_buf.virt = NULL;
return 0;
}
@@ -246,7 +246,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
int ret;
mfc_debug_enter();
- if (!dev->fw_virt_addr) {
+ if (!dev->fw_buf.virt) {
mfc_err("Firmware memory is not allocated.\n");
return -EINVAL;
}
OpenPOWER on IntegriCloud