cx18-queue.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * cx18 buffer queues
  4. *
  5. * Derived from ivtv-queue.h
  6. *
  7. * Copyright (C) 2007 Hans Verkuil <[email protected]>
  8. * Copyright (C) 2008 Andy Walls <[email protected]>
  9. */
  10. #define CX18_DMA_UNMAPPED ((u32) -1)
  11. /* cx18_buffer utility functions */
  12. static inline void cx18_buf_sync_for_cpu(struct cx18_stream *s,
  13. struct cx18_buffer *buf)
  14. {
  15. dma_sync_single_for_cpu(&s->cx->pci_dev->dev, buf->dma_handle,
  16. s->buf_size, s->dma);
  17. }
  18. static inline void cx18_buf_sync_for_device(struct cx18_stream *s,
  19. struct cx18_buffer *buf)
  20. {
  21. dma_sync_single_for_device(&s->cx->pci_dev->dev, buf->dma_handle,
  22. s->buf_size, s->dma);
  23. }
  24. void _cx18_mdl_sync_for_device(struct cx18_stream *s, struct cx18_mdl *mdl);
  25. static inline void cx18_mdl_sync_for_device(struct cx18_stream *s,
  26. struct cx18_mdl *mdl)
  27. {
  28. if (list_is_singular(&mdl->buf_list))
  29. cx18_buf_sync_for_device(s, list_first_entry(&mdl->buf_list,
  30. struct cx18_buffer,
  31. list));
  32. else
  33. _cx18_mdl_sync_for_device(s, mdl);
  34. }
  35. void cx18_buf_swap(struct cx18_buffer *buf);
  36. void _cx18_mdl_swap(struct cx18_mdl *mdl);
  37. static inline void cx18_mdl_swap(struct cx18_mdl *mdl)
  38. {
  39. if (list_is_singular(&mdl->buf_list))
  40. cx18_buf_swap(list_first_entry(&mdl->buf_list,
  41. struct cx18_buffer, list));
  42. else
  43. _cx18_mdl_swap(mdl);
  44. }
  45. /* cx18_queue utility functions */
  46. struct cx18_queue *_cx18_enqueue(struct cx18_stream *s, struct cx18_mdl *mdl,
  47. struct cx18_queue *q, int to_front);
  48. static inline
  49. struct cx18_queue *cx18_enqueue(struct cx18_stream *s, struct cx18_mdl *mdl,
  50. struct cx18_queue *q)
  51. {
  52. return _cx18_enqueue(s, mdl, q, 0); /* FIFO */
  53. }
  54. static inline
  55. struct cx18_queue *cx18_push(struct cx18_stream *s, struct cx18_mdl *mdl,
  56. struct cx18_queue *q)
  57. {
  58. return _cx18_enqueue(s, mdl, q, 1); /* LIFO */
  59. }
  60. void cx18_queue_init(struct cx18_queue *q);
  61. struct cx18_mdl *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q);
  62. struct cx18_mdl *cx18_queue_get_mdl(struct cx18_stream *s, u32 id,
  63. u32 bytesused);
  64. void cx18_flush_queues(struct cx18_stream *s);
  65. /* queue MDL reconfiguration helpers */
  66. void cx18_unload_queues(struct cx18_stream *s);
  67. void cx18_load_queues(struct cx18_stream *s);
  68. /* cx18_stream utility functions */
  69. int cx18_stream_alloc(struct cx18_stream *s);
  70. void cx18_stream_free(struct cx18_stream *s);