vpif_capture.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2009 Texas Instruments Inc
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef VPIF_CAPTURE_H
  19. #define VPIF_CAPTURE_H
  20. /* Header files */
  21. #include <media/videobuf2-dma-contig.h>
  22. #include <media/v4l2-device.h>
  23. #include "vpif.h"
  24. /* Macros */
  25. #define VPIF_CAPTURE_VERSION "0.0.2"
  26. #define VPIF_VALID_FIELD(field) (((V4L2_FIELD_ANY == field) || \
  27. (V4L2_FIELD_NONE == field)) || \
  28. (((V4L2_FIELD_INTERLACED == field) || \
  29. (V4L2_FIELD_SEQ_TB == field)) || \
  30. (V4L2_FIELD_SEQ_BT == field)))
  31. #define VPIF_CAPTURE_MAX_DEVICES 2
  32. #define VPIF_VIDEO_INDEX 0
  33. #define VPIF_NUMBER_OF_OBJECTS 1
  34. /* Enumerated data type to give id to each device per channel */
  35. enum vpif_channel_id {
  36. VPIF_CHANNEL0_VIDEO = 0,
  37. VPIF_CHANNEL1_VIDEO,
  38. };
  39. struct video_obj {
  40. enum v4l2_field buf_field;
  41. /* Currently selected or default standard */
  42. v4l2_std_id stdid;
  43. struct v4l2_dv_timings dv_timings;
  44. };
  45. struct vpif_cap_buffer {
  46. struct vb2_v4l2_buffer vb;
  47. struct list_head list;
  48. };
  49. struct common_obj {
  50. /* Pointer pointing to current v4l2_buffer */
  51. struct vpif_cap_buffer *cur_frm;
  52. /* Pointer pointing to current v4l2_buffer */
  53. struct vpif_cap_buffer *next_frm;
  54. /* Used to store pixel format */
  55. struct v4l2_format fmt;
  56. /* Buffer queue used in video-buf */
  57. struct vb2_queue buffer_queue;
  58. /* allocator-specific contexts for each plane */
  59. struct vb2_alloc_ctx *alloc_ctx;
  60. /* Queue of filled frames */
  61. struct list_head dma_queue;
  62. /* Used in video-buf */
  63. spinlock_t irqlock;
  64. /* lock used to access this structure */
  65. struct mutex lock;
  66. /* Function pointer to set the addresses */
  67. void (*set_addr) (unsigned long, unsigned long, unsigned long,
  68. unsigned long);
  69. /* offset where Y top starts from the starting of the buffer */
  70. u32 ytop_off;
  71. /* offset where Y bottom starts from the starting of the buffer */
  72. u32 ybtm_off;
  73. /* offset where C top starts from the starting of the buffer */
  74. u32 ctop_off;
  75. /* offset where C bottom starts from the starting of the buffer */
  76. u32 cbtm_off;
  77. /* Indicates width of the image data */
  78. u32 width;
  79. /* Indicates height of the image data */
  80. u32 height;
  81. };
  82. struct channel_obj {
  83. /* Identifies video device for this channel */
  84. struct video_device video_dev;
  85. /* Indicates id of the field which is being displayed */
  86. u32 field_id;
  87. /* flag to indicate whether decoder is initialized */
  88. u8 initialized;
  89. /* Identifies channel */
  90. enum vpif_channel_id channel_id;
  91. /* Current input */
  92. u32 input_idx;
  93. /* subdev corresponding to the current input, may be NULL */
  94. struct v4l2_subdev *sd;
  95. /* vpif configuration params */
  96. struct vpif_params vpifparams;
  97. /* common object array */
  98. struct common_obj common[VPIF_NUMBER_OF_OBJECTS];
  99. /* video object */
  100. struct video_obj video;
  101. };
  102. struct vpif_device {
  103. struct v4l2_device v4l2_dev;
  104. struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS];
  105. struct v4l2_subdev **sd;
  106. struct v4l2_async_notifier notifier;
  107. struct vpif_capture_config *config;
  108. };
  109. #endif /* VPIF_CAPTURE_H */