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