brintos

brintos / linux-shallow public Read only

0
0
Text · 2.3 KiB · 32b7fd3 Raw
84 lines · c
1/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */2/*3 * Wave5 series multi-standard codec IP - basic types4 *5 * Copyright (C) 2021-2023 CHIPS&MEDIA INC6 */7#ifndef __VPU_DRV_H__8#define __VPU_DRV_H__9 10#include <media/v4l2-ctrls.h>11#include <media/v4l2-ioctl.h>12#include <media/v4l2-event.h>13#include <media/v4l2-fh.h>14#include <media/videobuf2-v4l2.h>15#include <media/videobuf2-dma-contig.h>16#include <media/videobuf2-vmalloc.h>17#include "wave5-vpuconfig.h"18#include "wave5-vpuapi.h"19 20#define VPU_BUF_SYNC_TO_DEVICE 021#define VPU_BUF_SYNC_FROM_DEVICE 122 23struct vpu_src_buffer {24	struct v4l2_m2m_buffer	v4l2_m2m_buf;25	struct list_head	list;26	bool			consumed;27};28 29struct vpu_dst_buffer {30	struct v4l2_m2m_buffer v4l2_m2m_buf;31	bool                   display;32};33 34enum vpu_fmt_type {35	VPU_FMT_TYPE_CODEC = 0,36	VPU_FMT_TYPE_RAW   = 137};38 39struct vpu_format {40	unsigned int v4l2_pix_fmt;41	unsigned int max_width;42	unsigned int min_width;43	unsigned int max_height;44	unsigned int min_height;45};46 47static inline struct vpu_instance *wave5_to_vpu_inst(struct v4l2_fh *vfh)48{49	return container_of(vfh, struct vpu_instance, v4l2_fh);50}51 52static inline struct vpu_instance *wave5_ctrl_to_vpu_inst(struct v4l2_ctrl *vctrl)53{54	return container_of(vctrl->handler, struct vpu_instance, v4l2_ctrl_hdl);55}56 57static inline struct vpu_src_buffer *wave5_to_vpu_src_buf(struct vb2_v4l2_buffer *vbuf)58{59	return container_of(vbuf, struct vpu_src_buffer, v4l2_m2m_buf.vb);60}61 62static inline struct vpu_dst_buffer *wave5_to_vpu_dst_buf(struct vb2_v4l2_buffer *vbuf)63{64	return container_of(vbuf, struct vpu_dst_buffer, v4l2_m2m_buf.vb);65}66 67int wave5_vpu_wait_interrupt(struct vpu_instance *inst, unsigned int timeout);68 69int  wave5_vpu_dec_register_device(struct vpu_device *dev);70void wave5_vpu_dec_unregister_device(struct vpu_device *dev);71int  wave5_vpu_enc_register_device(struct vpu_device *dev);72void wave5_vpu_enc_unregister_device(struct vpu_device *dev);73static inline bool wave5_vpu_both_queues_are_streaming(struct vpu_instance *inst)74{75	struct vb2_queue *vq_cap =76		v4l2_m2m_get_vq(inst->v4l2_fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);77	struct vb2_queue *vq_out =78		v4l2_m2m_get_vq(inst->v4l2_fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);79 80	return vb2_is_streaming(vq_cap) && vb2_is_streaming(vq_out);81}82 83#endif84