linux/drivers/staging/media/davinci_vpfe/vpfe_video.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * Copyright (C) 2012 Texas Instruments Inc
   4 *
   5 * This program is free software; you can redistribute it and/or
   6 * modify it under the terms of the GNU General Public License as
   7 * published by the Free Software Foundation version 2.
   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 * Contributors:
  15 *      Manjunath Hadli <manjunath.hadli@ti.com>
  16 *      Prabhakar Lad <prabhakar.lad@ti.com>
  17 */
  18
  19#ifndef _DAVINCI_VPFE_VIDEO_H
  20#define _DAVINCI_VPFE_VIDEO_H
  21
  22#include <media/videobuf2-v4l2.h>
  23#include <media/videobuf2-dma-contig.h>
  24
  25struct vpfe_device;
  26
  27/*
  28 * struct vpfe_video_operations - VPFE video operations
  29 * @queue:      Resume streaming when a buffer is queued. Called on VIDIOC_QBUF
  30 *              if there was no buffer previously queued.
  31 */
  32struct vpfe_video_operations {
  33        int (*queue)(struct vpfe_device *vpfe_dev, unsigned long addr);
  34};
  35
  36enum vpfe_pipeline_stream_state {
  37        VPFE_PIPELINE_STREAM_STOPPED = 0,
  38        VPFE_PIPELINE_STREAM_CONTINUOUS = 1,
  39        VPFE_PIPELINE_STREAM_SINGLESHOT = 2,
  40};
  41
  42enum vpfe_video_state {
  43        /* indicates that buffer is not queued */
  44        VPFE_VIDEO_BUFFER_NOT_QUEUED = 0,
  45        /* indicates that buffer is queued */
  46        VPFE_VIDEO_BUFFER_QUEUED = 1,
  47};
  48
  49struct vpfe_pipeline {
  50        /* media pipeline */
  51        struct media_pipeline           *pipe;
  52        struct media_graph      graph;
  53        /* state of the pipeline, continuous,
  54         * single-shot or stopped
  55         */
  56        enum vpfe_pipeline_stream_state state;
  57        /* number of active input video entities */
  58        unsigned int                    input_num;
  59        /* number of active output video entities */
  60        unsigned int                    output_num;
  61        /* input video nodes in case of single-shot mode */
  62        struct vpfe_video_device        *inputs[10];
  63        /* capturing video nodes */
  64        struct vpfe_video_device        *outputs[10];
  65};
  66
  67#define to_vpfe_pipeline(__e) \
  68        container_of((__e)->pipe, struct vpfe_pipeline, pipe)
  69
  70#define to_vpfe_video(vdev) \
  71        container_of(vdev, struct vpfe_video_device, video_dev)
  72
  73struct vpfe_cap_buffer {
  74        struct vb2_v4l2_buffer vb;
  75        struct list_head list;
  76};
  77
  78struct vpfe_video_device {
  79        /* vpfe device */
  80        struct vpfe_device                      *vpfe_dev;
  81        /* video dev */
  82        struct video_device                     video_dev;
  83        /* media pad of video entity */
  84        struct media_pad                        pad;
  85        /* video operations supported by video device */
  86        const struct vpfe_video_operations      *ops;
  87        /* type of the video buffers used by user */
  88        enum v4l2_buf_type                      type;
  89        /* Indicates id of the field which is being captured */
  90        u32                                     field_id;
  91        /* pipeline for which video device is part of */
  92        struct vpfe_pipeline                    pipe;
  93        /* Indicates whether streaming started */
  94        u8                                      started;
  95        /* Indicates state of the stream */
  96        unsigned int                            state;
  97        /* current input at the sub device */
  98        int                                     current_input;
  99        /*
 100         * This field keeps track of type of buffer exchange mechanism
 101         * user has selected
 102         */
 103        enum v4l2_memory                        memory;
 104        /* number of open instances of the channel */
 105        u32                                     usrs;
 106        /* flag to indicate whether decoder is initialized */
 107        u8                                      initialized;
 108        /* skip frame count */
 109        u8                                      skip_frame_count;
 110        /* skip frame count init value */
 111        u8                                      skip_frame_count_init;
 112        /* time per frame for skipping */
 113        struct v4l2_fract                       timeperframe;
 114        /* ptr to currently selected sub device */
 115        struct vpfe_ext_subdev_info             *current_ext_subdev;
 116        /* Pointer pointing to current vpfe_cap_buffer */
 117        struct vpfe_cap_buffer                  *cur_frm;
 118        /* Pointer pointing to next vpfe_cap_buffer */
 119        struct vpfe_cap_buffer                  *next_frm;
 120        /* Used to store pixel format */
 121        struct v4l2_format                      fmt;
 122        struct vb2_queue                        buffer_queue;
 123        /* Queue of filled frames */
 124        struct list_head                        dma_queue;
 125        spinlock_t                              irqlock;
 126        /* IRQ lock for DMA queue */
 127        spinlock_t                              dma_queue_lock;
 128        /* lock used to serialize all video4linux ioctls */
 129        struct mutex                            lock;
 130        /* number of users performing IO */
 131        u32                                     io_usrs;
 132        /* Currently selected or default standard */
 133        v4l2_std_id                             stdid;
 134        /*
 135         * offset where second field starts from the starting of the
 136         * buffer for field separated YCbCr formats
 137         */
 138        u32                                     field_off;
 139};
 140
 141int vpfe_video_is_pipe_ready(struct vpfe_pipeline *pipe);
 142void vpfe_video_unregister(struct vpfe_video_device *video);
 143int vpfe_video_register(struct vpfe_video_device *video,
 144                        struct v4l2_device *vdev);
 145int vpfe_video_init(struct vpfe_video_device *video, const char *name);
 146void vpfe_video_process_buffer_complete(struct vpfe_video_device *video);
 147void vpfe_video_schedule_bottom_field(struct vpfe_video_device *video);
 148void vpfe_video_schedule_next_buffer(struct vpfe_video_device *video);
 149
 150#endif          /* _DAVINCI_VPFE_VIDEO_H */
 151