Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2009 Texas Instruments Inc |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef VPIF_CAPTURE_H |
| 7 | #define VPIF_CAPTURE_H |
| 8 | |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 9 | /* Header files */ |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 10 | #include <media/videobuf2-dma-contig.h> |
Lad, Prabhakar | 012eef7 | 2013-04-19 05:53:29 -0300 | [diff] [blame] | 11 | #include <media/v4l2-device.h> |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 12 | |
| 13 | #include "vpif.h" |
| 14 | |
| 15 | /* Macros */ |
Mauro Carvalho Chehab | 64dc3c1 | 2011-06-25 11:28:37 -0300 | [diff] [blame] | 16 | #define VPIF_CAPTURE_VERSION "0.0.2" |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 17 | |
| 18 | #define VPIF_VALID_FIELD(field) (((V4L2_FIELD_ANY == field) || \ |
| 19 | (V4L2_FIELD_NONE == field)) || \ |
| 20 | (((V4L2_FIELD_INTERLACED == field) || \ |
| 21 | (V4L2_FIELD_SEQ_TB == field)) || \ |
| 22 | (V4L2_FIELD_SEQ_BT == field))) |
| 23 | |
| 24 | #define VPIF_CAPTURE_MAX_DEVICES 2 |
| 25 | #define VPIF_VIDEO_INDEX 0 |
| 26 | #define VPIF_NUMBER_OF_OBJECTS 1 |
| 27 | |
| 28 | /* Enumerated data type to give id to each device per channel */ |
| 29 | enum vpif_channel_id { |
| 30 | VPIF_CHANNEL0_VIDEO = 0, |
| 31 | VPIF_CHANNEL1_VIDEO, |
| 32 | }; |
| 33 | |
| 34 | struct video_obj { |
| 35 | enum v4l2_field buf_field; |
| 36 | /* Currently selected or default standard */ |
| 37 | v4l2_std_id stdid; |
Hans Verkuil | 0598c17 | 2012-09-18 07:18:47 -0300 | [diff] [blame] | 38 | struct v4l2_dv_timings dv_timings; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 39 | }; |
| 40 | |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 41 | struct vpif_cap_buffer { |
Junghak Sung | 2d70071 | 2015-09-22 10:30:30 -0300 | [diff] [blame] | 42 | struct vb2_v4l2_buffer vb; |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 43 | struct list_head list; |
| 44 | }; |
| 45 | |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 46 | struct common_obj { |
| 47 | /* Pointer pointing to current v4l2_buffer */ |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 48 | struct vpif_cap_buffer *cur_frm; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 49 | /* Pointer pointing to current v4l2_buffer */ |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 50 | struct vpif_cap_buffer *next_frm; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 51 | /* Used to store pixel format */ |
| 52 | struct v4l2_format fmt; |
| 53 | /* Buffer queue used in video-buf */ |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 54 | struct vb2_queue buffer_queue; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 55 | /* Queue of filled frames */ |
| 56 | struct list_head dma_queue; |
Kevin Hilman | 62dd4ac | 2016-12-07 16:30:23 -0200 | [diff] [blame] | 57 | /* Protects the dma_queue field */ |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 58 | spinlock_t irqlock; |
| 59 | /* lock used to access this structure */ |
| 60 | struct mutex lock; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 61 | /* Function pointer to set the addresses */ |
| 62 | void (*set_addr) (unsigned long, unsigned long, unsigned long, |
| 63 | unsigned long); |
| 64 | /* offset where Y top starts from the starting of the buffer */ |
| 65 | u32 ytop_off; |
| 66 | /* offset where Y bottom starts from the starting of the buffer */ |
| 67 | u32 ybtm_off; |
| 68 | /* offset where C top starts from the starting of the buffer */ |
| 69 | u32 ctop_off; |
| 70 | /* offset where C bottom starts from the starting of the buffer */ |
| 71 | u32 cbtm_off; |
| 72 | /* Indicates width of the image data */ |
| 73 | u32 width; |
| 74 | /* Indicates height of the image data */ |
| 75 | u32 height; |
| 76 | }; |
| 77 | |
| 78 | struct channel_obj { |
| 79 | /* Identifies video device for this channel */ |
Lad, Prabhakar | 8eef666 | 2015-03-08 18:57:23 -0300 | [diff] [blame] | 80 | struct video_device video_dev; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 81 | /* Indicates id of the field which is being displayed */ |
| 82 | u32 field_id; |
| 83 | /* flag to indicate whether decoder is initialized */ |
| 84 | u8 initialized; |
| 85 | /* Identifies channel */ |
| 86 | enum vpif_channel_id channel_id; |
Hans Verkuil | 6f47c6c | 2012-09-20 09:06:22 -0300 | [diff] [blame] | 87 | /* Current input */ |
| 88 | u32 input_idx; |
Hans Verkuil | 178cce1 | 2012-09-20 09:06:30 -0300 | [diff] [blame] | 89 | /* subdev corresponding to the current input, may be NULL */ |
| 90 | struct v4l2_subdev *sd; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 91 | /* vpif configuration params */ |
| 92 | struct vpif_params vpifparams; |
| 93 | /* common object array */ |
| 94 | struct common_obj common[VPIF_NUMBER_OF_OBJECTS]; |
| 95 | /* video object */ |
| 96 | struct video_obj video; |
| 97 | }; |
| 98 | |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 99 | struct vpif_device { |
| 100 | struct v4l2_device v4l2_dev; |
| 101 | struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS]; |
| 102 | struct v4l2_subdev **sd; |
Lad, Prabhakar | 873229e | 2013-06-25 11:17:34 -0300 | [diff] [blame] | 103 | struct v4l2_async_notifier notifier; |
| 104 | struct vpif_capture_config *config; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 105 | }; |
| 106 | |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 107 | #endif /* VPIF_CAPTURE_H */ |