1/* 2 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License as 6 * published by the Free Software Foundation version 2. 7 * 8 * This program is distributed WITHOUT ANY WARRANTY of any 9 * kind, whether express or implied; without even the implied warranty 10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 */ 13#ifndef VPBE_DISPLAY_H 14#define VPBE_DISPLAY_H 15 16/* Header files */ 17#include <linux/videodev2.h> 18#include <media/v4l2-common.h> 19#include <media/v4l2-fh.h> 20#include <media/videobuf2-dma-contig.h> 21#include <media/davinci/vpbe_types.h> 22#include <media/davinci/vpbe_osd.h> 23#include <media/davinci/vpbe.h> 24 25#define VPBE_DISPLAY_MAX_DEVICES 2 26 27enum vpbe_display_device_id { 28 VPBE_DISPLAY_DEVICE_0, 29 VPBE_DISPLAY_DEVICE_1 30}; 31 32#define VPBE_DISPLAY_DRV_NAME "vpbe-display" 33 34#define VPBE_DISPLAY_MAJOR_RELEASE 1 35#define VPBE_DISPLAY_MINOR_RELEASE 0 36#define VPBE_DISPLAY_BUILD 1 37#define VPBE_DISPLAY_VERSION_CODE ((VPBE_DISPLAY_MAJOR_RELEASE << 16) | \ 38 (VPBE_DISPLAY_MINOR_RELEASE << 8) | \ 39 VPBE_DISPLAY_BUILD) 40 41#define VPBE_DISPLAY_VALID_FIELD(field) ((V4L2_FIELD_NONE == field) || \ 42 (V4L2_FIELD_ANY == field) || (V4L2_FIELD_INTERLACED == field)) 43 44/* Exp ratio numerator and denominator constants */ 45#define VPBE_DISPLAY_H_EXP_RATIO_N 9 46#define VPBE_DISPLAY_H_EXP_RATIO_D 8 47#define VPBE_DISPLAY_V_EXP_RATIO_N 6 48#define VPBE_DISPLAY_V_EXP_RATIO_D 5 49 50/* Zoom multiplication factor */ 51#define VPBE_DISPLAY_ZOOM_4X 4 52#define VPBE_DISPLAY_ZOOM_2X 2 53 54/* Structures */ 55struct display_layer_info { 56 int enable; 57 /* Layer ID used by Display Manager */ 58 enum osd_layer id; 59 struct osd_layer_config config; 60 enum osd_zoom_factor h_zoom; 61 enum osd_zoom_factor v_zoom; 62 enum osd_h_exp_ratio h_exp; 63 enum osd_v_exp_ratio v_exp; 64}; 65 66struct vpbe_disp_buffer { 67 struct vb2_buffer vb; 68 struct list_head list; 69}; 70 71/* vpbe display object structure */ 72struct vpbe_layer { 73 /* Pointer to the vpbe_display */ 74 struct vpbe_display *disp_dev; 75 /* Pointer pointing to current v4l2_buffer */ 76 struct vpbe_disp_buffer *cur_frm; 77 /* Pointer pointing to next v4l2_buffer */ 78 struct vpbe_disp_buffer *next_frm; 79 /* videobuf specific parameters 80 * Buffer queue used in video-buf 81 */ 82 struct vb2_queue buffer_queue; 83 /* allocator-specific contexts for each plane */ 84 struct vb2_alloc_ctx *alloc_ctx; 85 /* Queue of filled frames */ 86 struct list_head dma_queue; 87 /* Used in video-buf */ 88 spinlock_t irqlock; 89 /* V4l2 specific parameters */ 90 /* Identifies video device for this layer */ 91 struct video_device video_dev; 92 /* Used to store pixel format */ 93 struct v4l2_pix_format pix_fmt; 94 enum v4l2_field buf_field; 95 /* Video layer configuration params */ 96 struct display_layer_info layer_info; 97 /* vpbe specific parameters 98 * enable window for display 99 */ 100 unsigned char window_enable; 101 /* number of open instances of the layer */ 102 unsigned int usrs; 103 /* Indicates id of the field which is being displayed */ 104 unsigned int field_id; 105 /* Identifies device object */ 106 enum vpbe_display_device_id device_id; 107 /* facilitation of ioctl ops lock by v4l2*/ 108 struct mutex opslock; 109 u8 layer_first_int; 110}; 111 112/* vpbe device structure */ 113struct vpbe_display { 114 /* layer specific parameters */ 115 /* lock for isr updates to buf layers*/ 116 spinlock_t dma_queue_lock; 117 /* C-Plane offset from start of y-plane */ 118 unsigned int cbcr_ofst; 119 struct vpbe_layer *dev[VPBE_DISPLAY_MAX_DEVICES]; 120 struct vpbe_device *vpbe_dev; 121 struct osd_state *osd_device; 122}; 123 124struct buf_config_params { 125 unsigned char min_numbuffers; 126 unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES]; 127 unsigned int min_bufsize[VPBE_DISPLAY_MAX_DEVICES]; 128 unsigned int layer_bufsize[VPBE_DISPLAY_MAX_DEVICES]; 129}; 130 131#endif /* VPBE_DISPLAY_H */ 132