1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * VPIF display header file 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Copyright (C) 2009 Texas Instruments Incorporated - https://www.ti.com/ 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * This program is free software; you can redistribute it and/or 7*4882a593Smuzhiyun * modify it under the terms of the GNU General Public License as 8*4882a593Smuzhiyun * published by the Free Software Foundation version 2. 9*4882a593Smuzhiyun * 10*4882a593Smuzhiyun * This program is distributed .as is. WITHOUT ANY WARRANTY of any 11*4882a593Smuzhiyun * kind, whether express or implied; without even the implied warranty 12*4882a593Smuzhiyun * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*4882a593Smuzhiyun * GNU General Public License for more details. 14*4882a593Smuzhiyun */ 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #ifndef VPIF_DISPLAY_H 17*4882a593Smuzhiyun #define VPIF_DISPLAY_H 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun /* Header files */ 20*4882a593Smuzhiyun #include <media/videobuf2-dma-contig.h> 21*4882a593Smuzhiyun #include <media/v4l2-device.h> 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun #include "vpif.h" 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* Macros */ 26*4882a593Smuzhiyun #define VPIF_DISPLAY_VERSION "0.0.2" 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun #define VPIF_VALID_FIELD(field) \ 29*4882a593Smuzhiyun (((V4L2_FIELD_ANY == field) || (V4L2_FIELD_NONE == field)) || \ 30*4882a593Smuzhiyun (((V4L2_FIELD_INTERLACED == field) || (V4L2_FIELD_SEQ_TB == field)) || \ 31*4882a593Smuzhiyun (V4L2_FIELD_SEQ_BT == field))) 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun #define VPIF_DISPLAY_MAX_DEVICES (2) 34*4882a593Smuzhiyun #define VPIF_SLICED_BUF_SIZE (256) 35*4882a593Smuzhiyun #define VPIF_SLICED_MAX_SERVICES (3) 36*4882a593Smuzhiyun #define VPIF_VIDEO_INDEX (0) 37*4882a593Smuzhiyun #define VPIF_VBI_INDEX (1) 38*4882a593Smuzhiyun #define VPIF_HBI_INDEX (2) 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun /* Setting it to 1 as HBI/VBI support yet to be added , else 3*/ 41*4882a593Smuzhiyun #define VPIF_NUMOBJECTS (1) 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun /* Macros */ 44*4882a593Smuzhiyun #define ISALIGNED(a) (0 == ((a) & 7)) 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun /* enumerated data types */ 47*4882a593Smuzhiyun /* Enumerated data type to give id to each device per channel */ 48*4882a593Smuzhiyun enum vpif_channel_id { 49*4882a593Smuzhiyun VPIF_CHANNEL2_VIDEO = 0, /* Channel2 Video */ 50*4882a593Smuzhiyun VPIF_CHANNEL3_VIDEO, /* Channel3 Video */ 51*4882a593Smuzhiyun }; 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun /* structures */ 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun struct video_obj { 56*4882a593Smuzhiyun enum v4l2_field buf_field; 57*4882a593Smuzhiyun u32 latest_only; /* indicate whether to return 58*4882a593Smuzhiyun * most recent displayed frame only */ 59*4882a593Smuzhiyun v4l2_std_id stdid; /* Currently selected or default 60*4882a593Smuzhiyun * standard */ 61*4882a593Smuzhiyun struct v4l2_dv_timings dv_timings; 62*4882a593Smuzhiyun }; 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun struct vpif_disp_buffer { 65*4882a593Smuzhiyun struct vb2_v4l2_buffer vb; 66*4882a593Smuzhiyun struct list_head list; 67*4882a593Smuzhiyun }; 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun struct common_obj { 70*4882a593Smuzhiyun struct vpif_disp_buffer *cur_frm; /* Pointer pointing to current 71*4882a593Smuzhiyun * vb2_buffer */ 72*4882a593Smuzhiyun struct vpif_disp_buffer *next_frm; /* Pointer pointing to next 73*4882a593Smuzhiyun * vb2_buffer */ 74*4882a593Smuzhiyun struct v4l2_format fmt; /* Used to store the format */ 75*4882a593Smuzhiyun struct vb2_queue buffer_queue; /* Buffer queue used in 76*4882a593Smuzhiyun * video-buf */ 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun struct list_head dma_queue; /* Queue of filled frames */ 79*4882a593Smuzhiyun spinlock_t irqlock; /* Used in video-buf */ 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun /* channel specific parameters */ 82*4882a593Smuzhiyun struct mutex lock; /* lock used to access this 83*4882a593Smuzhiyun * structure */ 84*4882a593Smuzhiyun u32 ytop_off; /* offset of Y top from the 85*4882a593Smuzhiyun * starting of the buffer */ 86*4882a593Smuzhiyun u32 ybtm_off; /* offset of Y bottom from the 87*4882a593Smuzhiyun * starting of the buffer */ 88*4882a593Smuzhiyun u32 ctop_off; /* offset of C top from the 89*4882a593Smuzhiyun * starting of the buffer */ 90*4882a593Smuzhiyun u32 cbtm_off; /* offset of C bottom from the 91*4882a593Smuzhiyun * starting of the buffer */ 92*4882a593Smuzhiyun /* Function pointer to set the addresses */ 93*4882a593Smuzhiyun void (*set_addr)(unsigned long, unsigned long, 94*4882a593Smuzhiyun unsigned long, unsigned long); 95*4882a593Smuzhiyun u32 height; 96*4882a593Smuzhiyun u32 width; 97*4882a593Smuzhiyun }; 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun struct channel_obj { 100*4882a593Smuzhiyun /* V4l2 specific parameters */ 101*4882a593Smuzhiyun struct video_device video_dev; /* Identifies video device for 102*4882a593Smuzhiyun * this channel */ 103*4882a593Smuzhiyun u32 field_id; /* Indicates id of the field 104*4882a593Smuzhiyun * which is being displayed */ 105*4882a593Smuzhiyun u8 initialized; /* flag to indicate whether 106*4882a593Smuzhiyun * encoder is initialized */ 107*4882a593Smuzhiyun u32 output_idx; /* Current output index */ 108*4882a593Smuzhiyun struct v4l2_subdev *sd; /* Current output subdev(may be NULL) */ 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun enum vpif_channel_id channel_id;/* Identifies channel */ 111*4882a593Smuzhiyun struct vpif_params vpifparams; 112*4882a593Smuzhiyun struct common_obj common[VPIF_NUMOBJECTS]; 113*4882a593Smuzhiyun struct video_obj video; 114*4882a593Smuzhiyun }; 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun /* vpif device structure */ 117*4882a593Smuzhiyun struct vpif_device { 118*4882a593Smuzhiyun struct v4l2_device v4l2_dev; 119*4882a593Smuzhiyun struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS]; 120*4882a593Smuzhiyun struct v4l2_subdev **sd; 121*4882a593Smuzhiyun struct v4l2_async_notifier notifier; 122*4882a593Smuzhiyun struct vpif_display_config *config; 123*4882a593Smuzhiyun }; 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun #endif /* VPIF_DISPLAY_H */ 126