1e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* 2e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * DM646x display header file 3e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * 4e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ 5e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * 6e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * This program is free software; you can redistribute it and/or 7e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * modify it under the terms of the GNU General Public License as 8e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * published by the Free Software Foundation version 2. 9e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * 10e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * This program is distributed .as is. WITHOUT ANY WARRANTY of any 11e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * kind, whether express or implied; without even the implied warranty 12e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * GNU General Public License for more details. 14e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S */ 15e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 16e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#ifndef DAVINCIHD_DISPLAY_H 17e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define DAVINCIHD_DISPLAY_H 18e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 19e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* Header files */ 20e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#include <linux/videodev2.h> 21e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#include <media/v4l2-common.h> 22e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#include <media/v4l2-device.h> 23e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#include <media/videobuf-core.h> 24e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#include <media/videobuf-dma-contig.h> 25e13c692b1f97a6a4f753695b4f28b7f10e5d79aeManjunath Hadli#include <media/davinci/vpif_types.h> 26e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 27e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#include "vpif.h" 28e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 29e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* Macros */ 3064dc3c1a906467d90c24913b0b38dd13d9378f4fMauro Carvalho Chehab#define VPIF_DISPLAY_VERSION "0.0.2" 31e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 32e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define VPIF_VALID_FIELD(field) \ 33e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S (((V4L2_FIELD_ANY == field) || (V4L2_FIELD_NONE == field)) || \ 34e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S (((V4L2_FIELD_INTERLACED == field) || (V4L2_FIELD_SEQ_TB == field)) || \ 35e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S (V4L2_FIELD_SEQ_BT == field))) 36e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 37e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define VPIF_DISPLAY_MAX_DEVICES (2) 38e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define VPIF_SLICED_BUF_SIZE (256) 39e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define VPIF_SLICED_MAX_SERVICES (3) 40e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define VPIF_VIDEO_INDEX (0) 41e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define VPIF_VBI_INDEX (1) 42e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define VPIF_HBI_INDEX (2) 43e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 44e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* Setting it to 1 as HBI/VBI support yet to be added , else 3*/ 45e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define VPIF_NUMOBJECTS (1) 46e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 47e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* Macros */ 48e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#define ISALIGNED(a) (0 == ((a) & 7)) 49e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 50e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* enumerated data types */ 51e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* Enumerated data type to give id to each device per channel */ 52e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U Senum vpif_channel_id { 53e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S VPIF_CHANNEL2_VIDEO = 0, /* Channel2 Video */ 54e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S VPIF_CHANNEL3_VIDEO, /* Channel3 Video */ 55e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S}; 56e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 57e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* structures */ 58e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 59e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U Sstruct video_obj { 60e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S enum v4l2_field buf_field; 61e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 latest_only; /* indicate whether to return 62e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * most recent displayed frame only */ 63e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S v4l2_std_id stdid; /* Currently selected or default 64e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * standard */ 6540c8bcea6bc594c50abf3d3867bd49c8c039eb21Mats Randgaard u32 dv_preset; 66c027e165d2d901ecab485da5fee72ddce5da0297Mats Randgaard struct v4l2_bt_timings bt_timings; 67e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 output_id; /* Current output id */ 68e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S}; 69e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 70e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U Sstruct vbi_obj { 71e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S int num_services; 72e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct vpif_vbi_params vbiparams; /* vpif parameters for the raw 73e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * vbi data */ 74e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S}; 75e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 76e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U Sstruct common_obj { 77e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S /* Buffer specific parameters */ 78e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u8 *fbuffers[VIDEO_MAX_FRAME]; /* List of buffer pointers for 79e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * storing frames */ 80e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 numbuffers; /* number of buffers */ 81e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct videobuf_buffer *cur_frm; /* Pointer pointing to current 82e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * videobuf_buffer */ 83e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct videobuf_buffer *next_frm; /* Pointer pointing to next 84e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * videobuf_buffer */ 85e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S enum v4l2_memory memory; /* This field keeps track of 86e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * type of buffer exchange 87e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * method user has selected */ 88e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct v4l2_format fmt; /* Used to store the format */ 89e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct videobuf_queue buffer_queue; /* Buffer queue used in 90e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * video-buf */ 91e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct list_head dma_queue; /* Queue of filled frames */ 92e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S spinlock_t irqlock; /* Used in video-buf */ 93e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 94e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S /* channel specific parameters */ 95e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct mutex lock; /* lock used to access this 96e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * structure */ 97e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 io_usrs; /* number of users performing 98e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * IO */ 99e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u8 started; /* Indicates whether streaming 100e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * started */ 101e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 ytop_off; /* offset of Y top from the 102e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * starting of the buffer */ 103e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 ybtm_off; /* offset of Y bottom from the 104e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * starting of the buffer */ 105e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 ctop_off; /* offset of C top from the 106e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * starting of the buffer */ 107e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 cbtm_off; /* offset of C bottom from the 108e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * starting of the buffer */ 109e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S /* Function pointer to set the addresses */ 110e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S void (*set_addr) (unsigned long, unsigned long, 111e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S unsigned long, unsigned long); 112e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 height; 113e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 width; 114e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S}; 115e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 116e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U Sstruct channel_obj { 117e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S /* V4l2 specific parameters */ 118e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct video_device *video_dev; /* Identifies video device for 119e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * this channel */ 120e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct v4l2_prio_state prio; /* Used to keep track of state of 121e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * the priority */ 122e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S atomic_t usrs; /* number of open instances of 123e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * the channel */ 124e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 field_id; /* Indicates id of the field 125e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * which is being displayed */ 126e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u8 initialized; /* flag to indicate whether 127e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * encoder is initialized */ 128e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 129e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S enum vpif_channel_id channel_id;/* Identifies channel */ 130e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct vpif_params vpifparams; 131e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct common_obj common[VPIF_NUMOBJECTS]; 132e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct video_obj video; 133e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct vbi_obj vbi; 134e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S}; 135e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 136e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* File handle structure */ 137e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U Sstruct vpif_fh { 138e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct channel_obj *channel; /* pointer to channel object for 139e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * opened device */ 140e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u8 io_allowed[VPIF_NUMOBJECTS]; /* Indicates whether this file handle 141e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * is doing IO */ 142e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S enum v4l2_priority prio; /* Used to keep track priority of 143e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * this instance */ 144e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u8 initialized; /* Used to keep track of whether this 145e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * file handle has initialized 146e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S * channel or not */ 147e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S}; 148e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 149e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* vpif device structure */ 150e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U Sstruct vpif_device { 151e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct v4l2_device v4l2_dev; 152e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS]; 153e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S struct v4l2_subdev **sd; 154e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 155e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S}; 156e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 157e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U Sstruct vpif_config_params { 158e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS]; 159e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS]; 160e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS]; 161e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u8 min_numbuffers; 162e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S}; 163e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 164e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S/* Struct which keeps track of the line numbers for the sliced vbi service */ 165e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U Sstruct vpif_service_line { 166e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u16 service_id; 167e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u16 service_line[2]; 168e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u16 enc_service_id; 169e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S u8 bytestowrite; 170e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S}; 171e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S 172e7332e3a552f6e18b39f5b77ce964818d10c9743Chaithrika U S#endif /* DAVINCIHD_DISPLAY_H */ 173