vpif_capture.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifndef VPIF_CAPTURE_H
  15. #define VPIF_CAPTURE_H
  16. /* Header files */
  17. #include <media/videobuf2-dma-contig.h>
  18. #include <media/v4l2-device.h>
  19. #include "vpif.h"
  20. /* Macros */
  21. #define VPIF_CAPTURE_VERSION "0.0.2"
  22. #define VPIF_VALID_FIELD(field) (((V4L2_FIELD_ANY == field) || \
  23. (V4L2_FIELD_NONE == field)) || \
  24. (((V4L2_FIELD_INTERLACED == field) || \
  25. (V4L2_FIELD_SEQ_TB == field)) || \
  26. (V4L2_FIELD_SEQ_BT == field)))
  27. #define VPIF_CAPTURE_MAX_DEVICES 2
  28. #define VPIF_VIDEO_INDEX 0
  29. #define VPIF_NUMBER_OF_OBJECTS 1
  30. /* Enumerated data type to give id to each device per channel */
  31. enum vpif_channel_id {
  32. VPIF_CHANNEL0_VIDEO = 0,
  33. VPIF_CHANNEL1_VIDEO,
  34. };
  35. struct video_obj {
  36. enum v4l2_field buf_field;
  37. /* Currently selected or default standard */
  38. v4l2_std_id stdid;
  39. struct v4l2_dv_timings dv_timings;
  40. };
  41. struct vpif_cap_buffer {
  42. struct vb2_v4l2_buffer vb;
  43. struct list_head list;
  44. };
  45. struct common_obj {
  46. /* Pointer pointing to current v4l2_buffer */
  47. struct vpif_cap_buffer *cur_frm;
  48. /* Pointer pointing to current v4l2_buffer */
  49. struct vpif_cap_buffer *next_frm;
  50. /* Used to store pixel format */
  51. struct v4l2_format fmt;
  52. /* Buffer queue used in video-buf */
  53. struct vb2_queue buffer_queue;
  54. /* Queue of filled frames */
  55. struct list_head dma_queue;
  56. /* Protects the dma_queue field */
  57. spinlock_t irqlock;
  58. /* lock used to access this structure */
  59. struct mutex lock;
  60. /* Function pointer to set the addresses */
  61. void (*set_addr) (unsigned long, unsigned long, unsigned long,
  62. unsigned long);
  63. /* offset where Y top starts from the starting of the buffer */
  64. u32 ytop_off;
  65. /* offset where Y bottom starts from the starting of the buffer */
  66. u32 ybtm_off;
  67. /* offset where C top starts from the starting of the buffer */
  68. u32 ctop_off;
  69. /* offset where C bottom starts from the starting of the buffer */
  70. u32 cbtm_off;
  71. /* Indicates width of the image data */
  72. u32 width;
  73. /* Indicates height of the image data */
  74. u32 height;
  75. };
  76. struct channel_obj {
  77. /* Identifies video device for this channel */
  78. struct video_device video_dev;
  79. /* Indicates id of the field which is being displayed */
  80. u32 field_id;
  81. /* flag to indicate whether decoder is initialized */
  82. u8 initialized;
  83. /* Identifies channel */
  84. enum vpif_channel_id channel_id;
  85. /* Current input */
  86. u32 input_idx;
  87. /* subdev corresponding to the current input, may be NULL */
  88. struct v4l2_subdev *sd;
  89. /* vpif configuration params */
  90. struct vpif_params vpifparams;
  91. /* common object array */
  92. struct common_obj common[VPIF_NUMBER_OF_OBJECTS];
  93. /* video object */
  94. struct video_obj video;
  95. };
  96. struct vpif_device {
  97. struct v4l2_device v4l2_dev;
  98. struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS];
  99. struct v4l2_subdev **sd;
  100. struct v4l2_async_notifier notifier;
  101. struct vpif_capture_config *config;
  102. };
  103. #endif /* VPIF_CAPTURE_H */