brintos

brintos / linux-shallow public Read only

0
0
Text · 3.4 KiB · 32ade97 Raw
136 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Allwinner DE2 rotation driver4 *5 * Copyright (C) 2020 Jernej Skrabec <jernej.skrabec@siol.net>6 */7 8#ifndef _SUN8I_ROTATE_H_9#define _SUN8I_ROTATE_H_10 11#include <media/v4l2-ctrls.h>12#include <media/v4l2-device.h>13#include <media/v4l2-mem2mem.h>14#include <media/videobuf2-v4l2.h>15#include <media/videobuf2-dma-contig.h>16 17#include <linux/platform_device.h>18 19#define ROTATE_NAME		"sun8i-rotate"20 21#define ROTATE_GLB_CTL			0x0022#define ROTATE_GLB_CTL_START			BIT(31)23#define ROTATE_GLB_CTL_RESET			BIT(30)24#define ROTATE_GLB_CTL_BURST_LEN(x)		((x) << 16)25#define ROTATE_GLB_CTL_HFLIP			BIT(7)26#define ROTATE_GLB_CTL_VFLIP			BIT(6)27#define ROTATE_GLB_CTL_ROTATION(x)		((x) << 4)28#define ROTATE_GLB_CTL_MODE(x)			((x) << 0)29 30#define ROTATE_INT			0x0431#define ROTATE_INT_FINISH_IRQ_EN		BIT(16)32#define ROTATE_INT_FINISH_IRQ			BIT(0)33 34#define ROTATE_IN_FMT			0x2035#define ROTATE_IN_FMT_FORMAT(x)			((x) << 0)36 37#define ROTATE_IN_SIZE			0x2438#define ROTATE_IN_PITCH0		0x3039#define ROTATE_IN_PITCH1		0x3440#define ROTATE_IN_PITCH2		0x3841#define ROTATE_IN_ADDRL0		0x4042#define ROTATE_IN_ADDRH0		0x4443#define ROTATE_IN_ADDRL1		0x4844#define ROTATE_IN_ADDRH1		0x4c45#define ROTATE_IN_ADDRL2		0x5046#define ROTATE_IN_ADDRH2		0x5447#define ROTATE_OUT_SIZE			0x8448#define ROTATE_OUT_PITCH0		0x9049#define ROTATE_OUT_PITCH1		0x9450#define ROTATE_OUT_PITCH2		0x9851#define ROTATE_OUT_ADDRL0		0xA052#define ROTATE_OUT_ADDRH0		0xA453#define ROTATE_OUT_ADDRL1		0xA854#define ROTATE_OUT_ADDRH1		0xAC55#define ROTATE_OUT_ADDRL2		0xB056#define ROTATE_OUT_ADDRH2		0xB457 58#define ROTATE_BURST_8			0x0759#define ROTATE_BURST_16			0x0f60#define ROTATE_BURST_32			0x1f61#define ROTATE_BURST_64			0x3f62 63#define ROTATE_MODE_COPY_ROTATE		0x0164 65#define ROTATE_FORMAT_ARGB32		0x0066#define ROTATE_FORMAT_ABGR32		0x0167#define ROTATE_FORMAT_RGBA32		0x0268#define ROTATE_FORMAT_BGRA32		0x0369#define ROTATE_FORMAT_XRGB32		0x0470#define ROTATE_FORMAT_XBGR32		0x0571#define ROTATE_FORMAT_RGBX32		0x0672#define ROTATE_FORMAT_BGRX32		0x0773#define ROTATE_FORMAT_RGB24		0x0874#define ROTATE_FORMAT_BGR24		0x0975#define ROTATE_FORMAT_RGB565		0x0a76#define ROTATE_FORMAT_BGR565		0x0b77#define ROTATE_FORMAT_ARGB4444		0x0c78#define ROTATE_FORMAT_ABGR4444		0x0d79#define ROTATE_FORMAT_RGBA4444		0x0e80#define ROTATE_FORMAT_BGRA4444		0x0f81#define ROTATE_FORMAT_ARGB1555		0x1082#define ROTATE_FORMAT_ABGR1555		0x1183#define ROTATE_FORMAT_RGBA5551		0x1284#define ROTATE_FORMAT_BGRA5551		0x1385 86#define ROTATE_FORMAT_YUYV		0x2087#define ROTATE_FORMAT_UYVY		0x2188#define ROTATE_FORMAT_YVYU		0x2289#define ROTATE_FORMAT_VYUV		0x2390#define ROTATE_FORMAT_NV61		0x2491#define ROTATE_FORMAT_NV16		0x2592#define ROTATE_FORMAT_YUV422P		0x2693#define ROTATE_FORMAT_NV21		0x2894#define ROTATE_FORMAT_NV12		0x2995#define ROTATE_FORMAT_YUV420P		0x2A96 97#define ROTATE_SIZE(w, h)	(((h) - 1) << 16 | ((w) - 1))98 99#define ROTATE_MIN_WIDTH	8U100#define ROTATE_MIN_HEIGHT	8U101#define ROTATE_MAX_WIDTH	4096U102#define ROTATE_MAX_HEIGHT	4096U103 104struct rotate_ctx {105	struct v4l2_fh		fh;106	struct rotate_dev	*dev;107 108	struct v4l2_pix_format	src_fmt;109	struct v4l2_pix_format	dst_fmt;110 111	struct v4l2_ctrl_handler ctrl_handler;112 113	u32 hflip;114	u32 vflip;115	u32 rotate;116};117 118struct rotate_dev {119	struct v4l2_device	v4l2_dev;120	struct video_device	vfd;121	struct device		*dev;122	struct v4l2_m2m_dev	*m2m_dev;123 124	/* Device file mutex */125	struct mutex		dev_mutex;126 127	void __iomem		*base;128 129	struct clk		*bus_clk;130	struct clk		*mod_clk;131 132	struct reset_control	*rstc;133};134 135#endif136