/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2015-2016 MediaTek Inc. * Author: Houlong Wei <[email protected]> * Ming Hsiu Tsai <[email protected]> */ #ifndef __MTK_MDP_CORE_H__ #define __MTK_MDP_CORE_H__ #include <linux/videodev2.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-mem2mem.h> #include <media/videobuf2-core.h> #include <media/videobuf2-dma-contig.h> #include "mtk_mdp_vpu.h" #include "mtk_mdp_comp.h" #define MTK_MDP_MODULE_NAME … #define MTK_MDP_SHUTDOWN_TIMEOUT … #define MTK_MDP_MAX_CTRL_NUM … #define MTK_MDP_FMT_FLAG_OUTPUT … #define MTK_MDP_FMT_FLAG_CAPTURE … #define MTK_MDP_VPU_INIT … #define MTK_MDP_CTX_ERROR … /** * struct mtk_mdp_pix_align - alignment of image * @org_w: source alignment of width * @org_h: source alignment of height * @target_w: dst alignment of width * @target_h: dst alignment of height */ struct mtk_mdp_pix_align { … }; /** * struct mtk_mdp_fmt - the driver's internal color format data * @pixelformat: the fourcc code for this format, 0 if not applicable * @num_planes: number of physically non-contiguous data planes * @num_comp: number of logical data planes * @depth: per plane driver's private 'number of bits per pixel' * @row_depth: per plane driver's private 'number of bits per pixel per row' * @flags: flags indicating which operation mode format applies to * MTK_MDP_FMT_FLAG_OUTPUT is used in OUTPUT stream * MTK_MDP_FMT_FLAG_CAPTURE is used in CAPTURE stream * @align: pointer to a pixel alignment struct, NULL if using default value */ struct mtk_mdp_fmt { … }; /** * struct mtk_mdp_addr - the image processor physical address set * @addr: address of planes */ struct mtk_mdp_addr { … }; /* struct mtk_mdp_ctrls - the image processor control set * @rotate: rotation degree * @hflip: horizontal flip * @vflip: vertical flip * @global_alpha: the alpha value of current frame */ struct mtk_mdp_ctrls { … }; /** * struct mtk_mdp_frame - source/target frame properties * @width: SRC : SRCIMG_WIDTH, DST : OUTPUTDMA_WHOLE_IMG_WIDTH * @height: SRC : SRCIMG_HEIGHT, DST : OUTPUTDMA_WHOLE_IMG_HEIGHT * @crop: cropped(source)/scaled(destination) size * @payload: image size in bytes (w x h x bpp) * @pitch: bytes per line of image in memory * @addr: image frame buffer physical addresses * @fmt: color format pointer * @alpha: frame's alpha value */ struct mtk_mdp_frame { … }; /** * struct mtk_mdp_variant - image processor variant information * @pix_max: maximum limit of image size * @pix_min: minimum limit of image size * @pix_align: alignment of image * @h_scale_up_max: maximum scale-up in horizontal * @v_scale_up_max: maximum scale-up in vertical * @h_scale_down_max: maximum scale-down in horizontal * @v_scale_down_max: maximum scale-down in vertical */ struct mtk_mdp_variant { … }; /** * struct mtk_mdp_dev - abstraction for image processor entity * @lock: the mutex protecting this data structure * @vpulock: the mutex protecting the communication with VPU * @pdev: pointer to the image processor platform device * @variant: the IP variant information * @id: image processor device index (0..MTK_MDP_MAX_DEVS) * @comp_list: list of MDP function components * @m2m_dev: v4l2 memory-to-memory device data * @ctx_list: list of struct mtk_mdp_ctx * @vdev: video device for image processor driver * @v4l2_dev: V4L2 device to register video devices for. * @job_wq: processor work queue * @vpu_dev: VPU platform device * @ctx_num: counter of active MTK MDP context * @id_counter: An integer id given to the next opened context * @wdt_wq: work queue for VPU watchdog * @wdt_work: worker for VPU watchdog */ struct mtk_mdp_dev { … }; /** * struct mtk_mdp_ctx - the device context data * @list: link to ctx_list of mtk_mdp_dev * @s_frame: source frame properties * @d_frame: destination frame properties * @id: index of the context that this structure describes * @flags: additional flags for image conversion * @state: flags to keep track of user configuration * Protected by slock * @rotation: rotates the image by specified angle * @hflip: mirror the picture horizontally * @vflip: mirror the picture vertically * @mdp_dev: the image processor device this context applies to * @m2m_ctx: memory-to-memory device context * @fh: v4l2 file handle * @ctrl_handler: v4l2 controls handler * @ctrls: image processor control set * @ctrls_rdy: true if the control handler is initialized * @colorspace: enum v4l2_colorspace; supplemental to pixelformat * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding * @xfer_func: enum v4l2_xfer_func, colorspace transfer function * @quant: enum v4l2_quantization, colorspace quantization * @vpu: VPU instance * @slock: the mutex protecting mtp_mdp_ctx.state * @work: worker for image processing */ struct mtk_mdp_ctx { … }; extern int mtk_mdp_dbg_level; void mtk_mdp_register_component(struct mtk_mdp_dev *mdp, struct mtk_mdp_comp *comp); void mtk_mdp_unregister_component(struct mtk_mdp_dev *mdp, struct mtk_mdp_comp *comp); #if defined(DEBUG) #define mtk_mdp_dbg … #define mtk_mdp_err … #define mtk_mdp_dbg_enter … #define mtk_mdp_dbg_leave … #else #define mtk_mdp_dbg(level, fmt, args...) … #define mtk_mdp_err(fmt, args...) … #define mtk_mdp_dbg_enter() … #define mtk_mdp_dbg_leave() … #endif #endif /* __MTK_MDP_CORE_H__ */