184 lines · c
1/* SPDX-License-Identifier: GPL-2.0+ */2/*3 * vsp1_pipe.h -- R-Car VSP1 Pipeline4 *5 * Copyright (C) 2013-2015 Renesas Electronics Corporation6 *7 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)8 */9#ifndef __VSP1_PIPE_H__10#define __VSP1_PIPE_H__11 12#include <linux/dynamic_debug.h>13#include <linux/kref.h>14#include <linux/list.h>15#include <linux/spinlock.h>16#include <linux/wait.h>17 18#include <media/media-entity.h>19 20struct vsp1_dl_list;21struct vsp1_rwpf;22 23/*24 * struct vsp1_format_info - VSP1 video format description25 * @fourcc: V4L2 pixel format FCC identifier26 * @mbus: media bus format code27 * @hwfmt: VSP1 hardware format28 * @swap: swap register control29 * @planes: number of planes30 * @bpp: bits per pixel31 * @swap_yc: the Y and C components are swapped (Y comes before C)32 * @swap_uv: the U and V components are swapped (V comes before U)33 * @hsub: horizontal subsampling factor34 * @vsub: vertical subsampling factor35 * @alpha: has an alpha channel36 */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 bool alpha;49};50 51enum vsp1_pipeline_state {52 VSP1_PIPELINE_STOPPED,53 VSP1_PIPELINE_RUNNING,54 VSP1_PIPELINE_STOPPING,55};56 57/*58 * struct vsp1_partition - A description of a slice for the partition algorithm59 * @rpf: The RPF partition window configuration60 * @uds_sink: The UDS input partition window configuration61 * @uds_source: The UDS output partition window configuration62 * @sru: The SRU partition window configuration63 * @wpf: The WPF partition window configuration64 */65struct vsp1_partition {66 struct v4l2_rect rpf[VSP1_MAX_RPF];67 struct v4l2_rect uds_sink;68 struct v4l2_rect uds_source;69 struct v4l2_rect sru;70 struct v4l2_rect wpf;71};72 73/*74 * struct vsp1_pipeline - A VSP1 hardware pipeline75 * @pipe: the media pipeline76 * @irqlock: protects the pipeline state77 * @state: current state78 * @wq: wait queue to wait for state change completion79 * @frame_end: frame end interrupt handler80 * @lock: protects the pipeline use count and stream count81 * @kref: pipeline reference count82 * @stream_count: number of streaming video nodes83 * @buffers_ready: bitmask of RPFs and WPFs with at least one buffer available84 * @sequence: frame sequence number85 * @num_inputs: number of RPFs86 * @inputs: array of RPFs in the pipeline (indexed by RPF index)87 * @output: WPF at the output of the pipeline88 * @brx: BRx entity, if present89 * @hgo: HGO entity, if present90 * @hgt: HGT entity, if present91 * @lif: LIF entity, if present92 * @uds: UDS entity, if present93 * @uds_input: entity at the input of the UDS, if the UDS is present94 * @entities: list of entities in the pipeline95 * @stream_config: cached stream configuration for video pipelines96 * @configured: when false the @stream_config shall be written to the hardware97 * @interlaced: True when the pipeline is configured in interlaced mode98 * @partitions: The number of partitions used to process one frame99 * @part_table: The pre-calculated partitions used by the pipeline100 */101struct vsp1_pipeline {102 struct media_pipeline pipe;103 104 spinlock_t irqlock;105 enum vsp1_pipeline_state state;106 wait_queue_head_t wq;107 108 void (*frame_end)(struct vsp1_pipeline *pipe, unsigned int completion);109 110 struct mutex lock;111 struct kref kref;112 unsigned int stream_count;113 unsigned int buffers_ready;114 unsigned int sequence;115 116 unsigned int num_inputs;117 struct vsp1_rwpf *inputs[VSP1_MAX_RPF];118 struct vsp1_rwpf *output;119 struct vsp1_entity *brx;120 struct vsp1_entity *hgo;121 struct vsp1_entity *hgt;122 struct vsp1_entity *lif;123 struct vsp1_entity *uds;124 struct vsp1_entity *uds_input;125 126 /*127 * The order of this list must be identical to the order of the entities128 * in the pipeline, as it is assumed by the partition algorithm that we129 * can walk this list in sequence.130 */131 struct list_head entities;132 133 struct vsp1_dl_body *stream_config;134 bool configured;135 bool interlaced;136 137 unsigned int partitions;138 struct vsp1_partition *part_table;139 140 u32 underrun_count;141};142 143void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);144void vsp1_pipeline_init(struct vsp1_pipeline *pipe);145 146void __vsp1_pipeline_dump(struct _ddebug *, struct vsp1_pipeline *pipe,147 const char *msg);148 149#if defined(CONFIG_DYNAMIC_DEBUG) || \150 (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))151#define vsp1_pipeline_dump(pipe, msg) \152 _dynamic_func_call("vsp1_pipeline_dump()", __vsp1_pipeline_dump, pipe, msg)153#elif defined(DEBUG)154#define vsp1_pipeline_dump(pipe, msg) \155 __vsp1_pipeline_dump(NULL, pipe, msg)156#else157#define vsp1_pipeline_dump(pipe, msg) \158({ \159 if (0) \160 __vsp1_pipeline_dump(NULL, pipe, msg); \161})162#endif163 164void vsp1_pipeline_run(struct vsp1_pipeline *pipe);165bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe);166int vsp1_pipeline_stop(struct vsp1_pipeline *pipe);167bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe);168 169void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);170 171void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,172 struct vsp1_dl_body *dlb,173 unsigned int alpha);174 175void vsp1_pipeline_calculate_partition(struct vsp1_pipeline *pipe,176 struct vsp1_partition *partition,177 unsigned int div_size,178 unsigned int index);179 180const struct vsp1_format_info *vsp1_get_format_info(struct vsp1_device *vsp1,181 u32 fourcc);182 183#endif /* __VSP1_PIPE_H__ */184