Source
x
static void aspeed_video_update(struct aspeed_video *video, u32 reg, u32 clear,
// SPDX-License-Identifier: GPL-2.0+
#include <linux/atomic.h>
#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/v4l2-controls.h>
#include <linux/videodev2.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-device.h>
#include <media/v4l2-dv-timings.h>
#include <media/v4l2-event.h>
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-dma-contig.h>
#define DEVICE_NAME "aspeed-video"
#define ASPEED_VIDEO_JPEG_NUM_QUALITIES 12
#define ASPEED_VIDEO_JPEG_HEADER_SIZE 10
#define ASPEED_VIDEO_JPEG_QUANT_SIZE 116
#define ASPEED_VIDEO_JPEG_DCT_SIZE 34
#define MAX_FRAME_RATE 60
#define MAX_HEIGHT 1200
#define MAX_WIDTH 1920
#define MIN_HEIGHT 480
#define MIN_WIDTH 640
#define NUM_POLARITY_CHECKS 10
#define INVALID_RESOLUTION_RETRIES 2
#define INVALID_RESOLUTION_DELAY msecs_to_jiffies(250)
#define RESOLUTION_CHANGE_DELAY msecs_to_jiffies(500)
#define MODE_DETECT_TIMEOUT msecs_to_jiffies(500)
#define STOP_TIMEOUT msecs_to_jiffies(1000)
#define DIRECT_FETCH_THRESHOLD 0x0c0000 /* 1024 * 768 */
#define VE_MAX_SRC_BUFFER_SIZE 0x8ca000 /* 1920 * 1200, 32bpp */
#define VE_JPEG_HEADER_SIZE 0x006000 /* 512 * 12 * 4 */
#define VE_PROTECTION_KEY 0x000
#define VE_PROTECTION_KEY_UNLOCK 0x1a038aa8
#define VE_SEQ_CTRL 0x004
#define VE_SEQ_CTRL_TRIG_MODE_DET BIT(0)
#define VE_SEQ_CTRL_TRIG_CAPTURE BIT(1)
#define VE_SEQ_CTRL_FORCE_IDLE BIT(2)
#define VE_SEQ_CTRL_MULT_FRAME BIT(3)
#define VE_SEQ_CTRL_TRIG_COMP BIT(4)
#define VE_SEQ_CTRL_AUTO_COMP BIT(5)
#define VE_SEQ_CTRL_EN_WATCHDOG BIT(7)
#define VE_SEQ_CTRL_YUV420 BIT(10)
#define VE_SEQ_CTRL_COMP_FMT GENMASK(11, 10)
#define VE_SEQ_CTRL_HALT BIT(12)
#define VE_SEQ_CTRL_EN_WATCHDOG_COMP BIT(14)
#define VE_SEQ_CTRL_TRIG_JPG BIT(15)
#define VE_SEQ_CTRL_CAP_BUSY BIT(16)
#define VE_SEQ_CTRL_COMP_BUSY BIT(18)
#ifdef CONFIG_MACH_ASPEED_G5
#define VE_SEQ_CTRL_JPEG_MODE BIT(13) /* AST2500 */
#else
#define VE_SEQ_CTRL_JPEG_MODE BIT(8) /* AST2400 */
#endif /* CONFIG_MACH_ASPEED_G5 */
#define VE_CTRL 0x008
#define VE_CTRL_HSYNC_POL BIT(0)
#define VE_CTRL_VSYNC_POL BIT(1)
#define VE_CTRL_SOURCE BIT(2)
#define VE_CTRL_INT_DE BIT(4)
#define VE_CTRL_DIRECT_FETCH BIT(5)
#define VE_CTRL_YUV BIT(6)
#define VE_CTRL_RGB BIT(7)
#define VE_CTRL_CAPTURE_FMT GENMASK(7, 6)
#define VE_CTRL_AUTO_OR_CURSOR BIT(8)
#define VE_CTRL_CLK_INVERSE BIT(11)