vdin_vf.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * VDIN vframe support
  3. *
  4. * Author: Bobby Yang <bo.yang@amlogic.com>
  5. *
  6. * Copyright (C) 2010 Amlogic Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #ifndef __VDIN_VF_H
  14. #define __VDIN_VF_H
  15. /* Standard Linux Headers */
  16. #include <linux/types.h>
  17. #include <linux/kernel.h>
  18. #include <linux/spinlock.h>
  19. #include <linux/list.h>
  20. /* Amlogic Linux Headers */
  21. #include <linux/amports/vframe.h>
  22. #define VF_LOG_EN
  23. #ifdef VF_LOG_EN
  24. #define VF_LOG_LEN 200
  25. /* only log frontend opertations */
  26. #define VF_LOG_FE
  27. /* only log backend opertations */
  28. #define VF_LOG_BE
  29. typedef enum vf_operation_e {
  30. VF_OPERATION_INIT = 0,
  31. VF_OPERATION_FPEEK,
  32. VF_OPERATION_FGET,
  33. VF_OPERATION_FPUT,
  34. VF_OPERATION_BPEEK,
  35. VF_OPERATION_BGET,
  36. VF_OPERATION_BPUT,
  37. VF_OPERATION_FREE,
  38. } vf_operation_t;
  39. typedef enum vf_status_e {
  40. VF_STATUS_WL = 0, // In write list
  41. VF_STATUS_WM, // In write mode
  42. VF_STATUS_RL, // In read list
  43. VF_STATUS_RM, // In read mode
  44. VF_STATUS_WT, // In wait list
  45. VF_STATUS_SL,
  46. } vf_status_t;
  47. typedef struct vf_log_s {
  48. /*
  49. * master
  50. */
  51. // [ 0][ n] 1: buf[n] is in write list
  52. // [ 1][ n] 1: buf[n] is in write mode
  53. // [ 2][ n] 1: buf[n] is in read list
  54. // [ 3][ n] 1: buf[n] is in read mode
  55. // [ 4][ n] 1: buf[n] is in wait list
  56. /*
  57. * slave
  58. */
  59. // [ 5][ n] 1: buf[n] is in write list
  60. // [ 6][ n] 1: buf[n] is in write mode
  61. // [ 7][ n] 1: buf[n] is in read list
  62. // [ 8][ n] 1: buf[n] is in read mode
  63. // [ 9][ n] 1: buf[n] is in wait list
  64. // [10][ 7] 1: operation failure
  65. // [6:3] reserved
  66. // [2:0] operation ID
  67. unsigned char log_buf[VF_LOG_LEN][11];
  68. unsigned int log_cur;
  69. struct timeval log_time[VF_LOG_LEN];
  70. } vf_log_t;
  71. #endif
  72. #define VF_FLAG_NORMAL_FRAME 0x00000001
  73. typedef struct vf_entry {
  74. struct vframe_s vf;
  75. enum vf_status_e status;
  76. struct list_head list;
  77. unsigned int flag;
  78. } vf_entry_t;
  79. typedef struct vf_pool {
  80. unsigned int max_size, size;
  81. struct vf_entry *master;
  82. struct vf_entry *slave;
  83. struct list_head wr_list; /* vf_entry */
  84. unsigned int wr_list_size;
  85. struct list_head *wr_next;
  86. struct list_head rd_list; /* vf_entry */
  87. unsigned int rd_list_size;
  88. struct list_head wt_list; /* vframe_s */
  89. spinlock_t lock;
  90. #ifdef VF_LOG_EN
  91. struct vf_log_s log;
  92. #endif
  93. } vf_pool_t;
  94. extern void vf_log_init(struct vf_pool *p);
  95. extern void vf_log_print(struct vf_pool *p);
  96. extern struct vf_entry *vf_get_master(struct vf_pool *p, int index);
  97. extern struct vf_entry *vf_get_slave(struct vf_pool *p, int index);
  98. extern struct vf_pool *vf_pool_alloc(int size);
  99. extern int vf_pool_init(struct vf_pool *p, int size);
  100. extern void vf_pool_free(struct vf_pool *p);
  101. extern struct vf_entry *provider_vf_peek(struct vf_pool *p);
  102. extern struct vf_entry *provider_vf_get(struct vf_pool *p);
  103. extern void provider_vf_put(struct vf_entry *vf, struct vf_pool *p);
  104. extern struct vf_entry *receiver_vf_peek(struct vf_pool *p);
  105. extern struct vf_entry *receiver_vf_get(struct vf_pool *p);
  106. extern void receiver_vf_put(struct vframe_s *vf, struct vf_pool *p);
  107. extern struct vframe_s *vdin_vf_peek(void* op_arg);
  108. extern struct vframe_s *vdin_vf_get (void* op_arg);
  109. extern void vdin_vf_put(struct vframe_s *vf, void* op_arg);
  110. #endif