linux/drivers/media/platform/vsp1/vsp1_video.h
<<
>>
Prefs
   1/*
   2 * vsp1_video.h  --  R-Car VSP1 Video Node
   3 *
   4 * Copyright (C) 2013 Renesas Corporation
   5 *
   6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
   7 *
   8 * This program is free software; you can redistribute it and/or modify
   9 * it under the terms of the GNU General Public License as published by
  10 * the Free Software Foundation; either version 2 of the License, or
  11 * (at your option) any later version.
  12 */
  13#ifndef __VSP1_VIDEO_H__
  14#define __VSP1_VIDEO_H__
  15
  16#include <linux/list.h>
  17#include <linux/spinlock.h>
  18#include <linux/wait.h>
  19
  20#include <media/media-entity.h>
  21#include <media/videobuf2-core.h>
  22
  23struct vsp1_video;
  24
  25/*
  26 * struct vsp1_format_info - VSP1 video format description
  27 * @mbus: media bus format code
  28 * @fourcc: V4L2 pixel format FCC identifier
  29 * @planes: number of planes
  30 * @bpp: bits per pixel
  31 * @hwfmt: VSP1 hardware format
  32 * @swap_yc: the Y and C components are swapped (Y comes before C)
  33 * @swap_uv: the U and V components are swapped (V comes before U)
  34 * @hsub: horizontal subsampling factor
  35 * @vsub: vertical subsampling factor
  36 */
  37struct vsp1_format_info {
  38        u32 fourcc;
  39        unsigned int mbus;
  40        unsigned int hwfmt;
  41        unsigned int swap;
  42        unsigned int planes;
  43        unsigned int bpp[3];
  44        bool swap_yc;
  45        bool swap_uv;
  46        unsigned int hsub;
  47        unsigned int vsub;
  48};
  49
  50enum vsp1_pipeline_state {
  51        VSP1_PIPELINE_STOPPED,
  52        VSP1_PIPELINE_RUNNING,
  53        VSP1_PIPELINE_STOPPING,
  54};
  55
  56/*
  57 * struct vsp1_pipeline - A VSP1 hardware pipeline
  58 * @media: the media pipeline
  59 * @irqlock: protects the pipeline state
  60 * @lock: protects the pipeline use count and stream count
  61 */
  62struct vsp1_pipeline {
  63        struct media_pipeline pipe;
  64
  65        spinlock_t irqlock;
  66        enum vsp1_pipeline_state state;
  67        wait_queue_head_t wq;
  68
  69        struct mutex lock;
  70        unsigned int use_count;
  71        unsigned int stream_count;
  72        unsigned int buffers_ready;
  73
  74        unsigned int num_video;
  75        unsigned int num_inputs;
  76        struct vsp1_rwpf *inputs[VPS1_MAX_RPF];
  77        struct vsp1_rwpf *output;
  78        struct vsp1_entity *lif;
  79
  80        struct list_head entities;
  81};
  82
  83static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
  84{
  85        if (likely(e->pipe))
  86                return container_of(e->pipe, struct vsp1_pipeline, pipe);
  87        else
  88                return NULL;
  89}
  90
  91struct vsp1_video_buffer {
  92        struct vsp1_video *video;
  93        struct vb2_buffer buf;
  94        struct list_head queue;
  95
  96        dma_addr_t addr[3];
  97        unsigned int length[3];
  98};
  99
 100static inline struct vsp1_video_buffer *
 101to_vsp1_video_buffer(struct vb2_buffer *vb)
 102{
 103        return container_of(vb, struct vsp1_video_buffer, buf);
 104}
 105
 106struct vsp1_video_operations {
 107        void (*queue)(struct vsp1_video *video, struct vsp1_video_buffer *buf);
 108};
 109
 110struct vsp1_video {
 111        struct vsp1_device *vsp1;
 112        struct vsp1_entity *rwpf;
 113
 114        const struct vsp1_video_operations *ops;
 115
 116        struct video_device video;
 117        enum v4l2_buf_type type;
 118        struct media_pad pad;
 119
 120        struct mutex lock;
 121        struct v4l2_pix_format_mplane format;
 122        const struct vsp1_format_info *fmtinfo;
 123
 124        struct vsp1_pipeline pipe;
 125        unsigned int pipe_index;
 126
 127        struct vb2_queue queue;
 128        void *alloc_ctx;
 129        spinlock_t irqlock;
 130        struct list_head irqqueue;
 131        unsigned int sequence;
 132};
 133
 134static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
 135{
 136        return container_of(vdev, struct vsp1_video, video);
 137}
 138
 139int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf);
 140void vsp1_video_cleanup(struct vsp1_video *video);
 141
 142void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
 143
 144#endif /* __VSP1_VIDEO_H__ */
 145