s5p_mfc_opr.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
  3. *
  4. * Samsung MFC (Multi Function Codec - FIMV) driver
  5. * This file contains hw related functions.
  6. *
  7. * Kamil Debski, Copyright (c) 2012 Samsung Electronics Co., Ltd.
  8. * http://www.samsung.com/
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include "s5p_mfc_debug.h"
  15. #include "s5p_mfc_opr.h"
  16. #include "s5p_mfc_opr_v5.h"
  17. #include "s5p_mfc_opr_v6.h"
  18. static struct s5p_mfc_hw_ops *s5p_mfc_ops;
  19. void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev)
  20. {
  21. if (IS_MFCV6(dev)) {
  22. s5p_mfc_ops = s5p_mfc_init_hw_ops_v6();
  23. dev->warn_start = S5P_FIMV_ERR_WARNINGS_START_V6;
  24. } else {
  25. s5p_mfc_ops = s5p_mfc_init_hw_ops_v5();
  26. dev->warn_start = S5P_FIMV_ERR_WARNINGS_START;
  27. }
  28. dev->mfc_ops = s5p_mfc_ops;
  29. }
  30. int s5p_mfc_alloc_priv_buf(struct device *dev,
  31. struct s5p_mfc_priv_buf *b)
  32. {
  33. mfc_debug(3, "Allocating priv: %d\n", b->size);
  34. b->virt = dma_alloc_coherent(dev, b->size, &b->dma, GFP_KERNEL);
  35. if (!b->virt) {
  36. mfc_err("Allocating private buffer failed\n");
  37. return -ENOMEM;
  38. }
  39. mfc_debug(3, "Allocated addr %p %08x\n", b->virt, b->dma);
  40. return 0;
  41. }
  42. void s5p_mfc_release_priv_buf(struct device *dev,
  43. struct s5p_mfc_priv_buf *b)
  44. {
  45. if (b->virt) {
  46. dma_free_coherent(dev, b->size, b->virt, b->dma);
  47. b->virt = NULL;
  48. b->dma = 0;
  49. b->size = 0;
  50. }
  51. }