linux/drivers/media/platform/davinci/vpif_capture.h
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2009 Texas Instruments Inc
   3 *
   4 * This program is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License as published by
   6 * the Free Software Foundation; either version 2 of the License, or
   7 * (at your option) any later version.
   8 *
   9 * This program is distributed in the hope that it will be useful,
  10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12 * GNU General Public License for more details.
  13 *
  14 * You should have received a copy of the GNU General Public License
  15 * along with this program; if not, write to the Free Software
  16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  17 */
  18
  19#ifndef VPIF_CAPTURE_H
  20#define VPIF_CAPTURE_H
  21
  22#ifdef __KERNEL__
  23
  24/* Header files */
  25#include <media/videobuf2-dma-contig.h>
  26#include <media/v4l2-device.h>
  27
  28#include "vpif.h"
  29
  30/* Macros */
  31#define VPIF_CAPTURE_VERSION            "0.0.2"
  32
  33#define VPIF_VALID_FIELD(field)         (((V4L2_FIELD_ANY == field) || \
  34        (V4L2_FIELD_NONE == field)) || \
  35        (((V4L2_FIELD_INTERLACED == field) || \
  36        (V4L2_FIELD_SEQ_TB == field)) || \
  37        (V4L2_FIELD_SEQ_BT == field)))
  38
  39#define VPIF_CAPTURE_MAX_DEVICES        2
  40#define VPIF_VIDEO_INDEX                0
  41#define VPIF_NUMBER_OF_OBJECTS          1
  42
  43/* Enumerated data type to give id to each device per channel */
  44enum vpif_channel_id {
  45        VPIF_CHANNEL0_VIDEO = 0,
  46        VPIF_CHANNEL1_VIDEO,
  47};
  48
  49struct video_obj {
  50        enum v4l2_field buf_field;
  51        /* Currently selected or default standard */
  52        v4l2_std_id stdid;
  53        struct v4l2_dv_timings dv_timings;
  54};
  55
  56struct vpif_cap_buffer {
  57        struct vb2_buffer vb;
  58        struct list_head list;
  59};
  60
  61struct common_obj {
  62        /* Pointer pointing to current v4l2_buffer */
  63        struct vpif_cap_buffer *cur_frm;
  64        /* Pointer pointing to current v4l2_buffer */
  65        struct vpif_cap_buffer *next_frm;
  66        /*
  67         * This field keeps track of type of buffer exchange mechanism
  68         * user has selected
  69         */
  70        enum v4l2_memory memory;
  71        /* Used to store pixel format */
  72        struct v4l2_format fmt;
  73        /* Buffer queue used in video-buf */
  74        struct vb2_queue buffer_queue;
  75        /* allocator-specific contexts for each plane */
  76        struct vb2_alloc_ctx *alloc_ctx;
  77        /* Queue of filled frames */
  78        struct list_head dma_queue;
  79        /* Used in video-buf */
  80        spinlock_t irqlock;
  81        /* lock used to access this structure */
  82        struct mutex lock;
  83        /* number of users performing IO */
  84        u32 io_usrs;
  85        /* Indicates whether streaming started */
  86        u8 started;
  87        /* Function pointer to set the addresses */
  88        void (*set_addr) (unsigned long, unsigned long, unsigned long,
  89                          unsigned long);
  90        /* offset where Y top starts from the starting of the buffer */
  91        u32 ytop_off;
  92        /* offset where Y bottom starts from the starting of the buffer */
  93        u32 ybtm_off;
  94        /* offset where C top starts from the starting of the buffer */
  95        u32 ctop_off;
  96        /* offset where C bottom starts from the starting of the buffer */
  97        u32 cbtm_off;
  98        /* Indicates width of the image data */
  99        u32 width;
 100        /* Indicates height of the image data */
 101        u32 height;
 102};
 103
 104struct channel_obj {
 105        /* Identifies video device for this channel */
 106        struct video_device *video_dev;
 107        /* Used to keep track of state of the priority */
 108        struct v4l2_prio_state prio;
 109        /* number of open instances of the channel */
 110        int usrs;
 111        /* Indicates id of the field which is being displayed */
 112        u32 field_id;
 113        /* flag to indicate whether decoder is initialized */
 114        u8 initialized;
 115        /* Identifies channel */
 116        enum vpif_channel_id channel_id;
 117        /* Current input */
 118        u32 input_idx;
 119        /* subdev corresponding to the current input, may be NULL */
 120        struct v4l2_subdev *sd;
 121        /* vpif configuration params */
 122        struct vpif_params vpifparams;
 123        /* common object array */
 124        struct common_obj common[VPIF_NUMBER_OF_OBJECTS];
 125        /* video object */
 126        struct video_obj video;
 127};
 128
 129/* File handle structure */
 130struct vpif_fh {
 131        /* pointer to channel object for opened device */
 132        struct channel_obj *channel;
 133        /* Indicates whether this file handle is doing IO */
 134        u8 io_allowed[VPIF_NUMBER_OF_OBJECTS];
 135        /* Used to keep track priority of this instance */
 136        enum v4l2_priority prio;
 137        /* Used to indicate channel is initialize or not */
 138        u8 initialized;
 139};
 140
 141struct vpif_device {
 142        struct v4l2_device v4l2_dev;
 143        struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS];
 144        struct v4l2_subdev **sd;
 145        struct v4l2_async_notifier notifier;
 146        struct vpif_capture_config *config;
 147};
 148
 149struct vpif_config_params {
 150        u8 min_numbuffers;
 151        u8 numbuffers[VPIF_CAPTURE_NUM_CHANNELS];
 152        s8 device_type;
 153        u32 min_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
 154        u32 channel_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
 155        u8 default_device[VPIF_CAPTURE_NUM_CHANNELS];
 156        u32 video_limit[VPIF_CAPTURE_NUM_CHANNELS];
 157        u8 max_device_type;
 158};
 159
 160#endif                          /* End of __KERNEL__ */
 161#endif                          /* VPIF_CAPTURE_H */
 162