Skip to content

Commit

Permalink
[media] s5p-mfc: Change internal buffer allocation from vb2 ops to dm…
Browse files Browse the repository at this point in the history
…a_alloc_coherent

Change internal buffer allocation from vb2 memory ops call to direct
calls of dma_alloc_coherent. This change shortens the code and makes it
much more readable.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Kamil Debski authored and Mauro Carvalho Chehab committed Jan 6, 2013
1 parent ef89fff commit 317b4ca
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 229 deletions.
20 changes: 4 additions & 16 deletions drivers/media/platform/s5p-mfc/s5p_mfc_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,9 @@ struct s5p_mfc_codec_ops {
* flushed
* @head_processed: flag mentioning whether the header data is processed
* completely or not
* @bank1_buf: handle to memory allocated for temporary buffers from
* @bank1: handle to memory allocated for temporary buffers from
* memory bank 1
* @bank1_phys: address of the temporary buffers from memory bank 1
* @bank1_size: size of the memory allocated for temporary buffers from
* memory bank 1
* @bank2_buf: handle to memory allocated for temporary buffers from
* memory bank 2
* @bank2_phys: address of the temporary buffers from memory bank 2
* @bank2_size: size of the memory allocated for temporary buffers from
* @bank2: handle to memory allocated for temporary buffers from
* memory bank 2
* @capture_state: state of the capture buffers queue
* @output_state: state of the output buffers queue
Expand Down Expand Up @@ -584,14 +578,8 @@ struct s5p_mfc_ctx {
unsigned int dpb_flush_flag;
unsigned int head_processed;

/* Buffers */
void *bank1_buf;
size_t bank1_phys;
size_t bank1_size;

void *bank2_buf;
size_t bank2_phys;
size_t bank2_size;
struct s5p_mfc_priv_buf bank1;
struct s5p_mfc_priv_buf bank2;

enum s5p_mfc_queue_state capture_state;
enum s5p_mfc_queue_state output_state;
Expand Down
30 changes: 30 additions & 0 deletions drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* published by the Free Software Foundation.
*/

#include "s5p_mfc_debug.h"
#include "s5p_mfc_opr.h"
#include "s5p_mfc_opr_v5.h"
#include "s5p_mfc_opr_v6.h"
Expand All @@ -29,3 +30,32 @@ void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev)
}
dev->mfc_ops = s5p_mfc_ops;
}

int s5p_mfc_alloc_priv_buf(struct device *dev,
struct s5p_mfc_priv_buf *b)
{

mfc_debug(3, "Allocating priv: %d\n", b->size);

b->virt = dma_alloc_coherent(dev, b->size, &b->dma, GFP_KERNEL);

if (!b->virt) {
mfc_err("Allocating private buffer failed\n");
return -ENOMEM;
}

mfc_debug(3, "Allocated addr %p %08x\n", b->virt, b->dma);
return 0;
}

void s5p_mfc_release_priv_buf(struct device *dev,
struct s5p_mfc_priv_buf *b)
{
if (b->virt) {
dma_free_coherent(dev, b->size, b->virt, b->dma);
b->virt = 0;
b->dma = 0;
b->size = 0;
}
}

5 changes: 5 additions & 0 deletions drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@ struct s5p_mfc_hw_ops {
};

void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev);
int s5p_mfc_alloc_priv_buf(struct device *dev,
struct s5p_mfc_priv_buf *b);
void s5p_mfc_release_priv_buf(struct device *dev,
struct s5p_mfc_priv_buf *b);


#endif /* S5P_MFC_OPR_H_ */
Loading

0 comments on commit 317b4ca

Please sign in to comment.