summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/starfive/starfive_drm_crtc.h
blob: b04706ae82820238a6e921f256879d9eb149cbab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2021 StarFive Technology Co., Ltd.
 */
#ifndef _STARFIVE_DRM_CRTC_H
#define _STARFIVE_DRM_CRTC_H
#include <drm/drm_crtc.h>

enum COLOR_FORMAT {
	COLOR_YUV422_UYVY = 0,  //00={Y1,V0,Y0,U0}
	COLOR_YUV422_VYUY = 1,  //01={Y1,U0,Y0,V0}
	COLOR_YUV422_YUYV = 2,  //10={V0,Y1,U0,Y0}
	COLOR_YUV422_YVYU = 3,  //11={U0,Y1,V0,Y0}

	COLOR_YUV420P,
	COLOR_YUV420_NV21,
	COLOR_YUV420_NV12,

	COLOR_RGB888_ARGB,
	COLOR_RGB888_ABGR,
	COLOR_RGB888_RGBA,
	COLOR_RGB888_BGRA,
	COLOR_RGB565,
};

struct starfive_crtc_state {
	struct drm_crtc_state base;
};

#define to_starfive_crtc_state(s) \
		container_of(s, struct starfive_crtc_state, base)

struct starfive_crtc {
	struct drm_crtc		crtc;
	struct device		*dev;
	struct drm_device	*drm_dev;
	bool is_enabled;

	void __iomem	*base_clk;	// 0x12240000
	void __iomem	*base_rst;	// 0x12250000
	void __iomem	*base_syscfg;	// 0x12260000
	void __iomem	*base_vpp0;	// 0x12040000
	void __iomem	*base_vpp1;	// 0x12080000
	void __iomem	*base_vpp2;	// 0x120c0000
	void __iomem	*base_lcdc;	// 0x12000000

	struct clk *clk_disp_axi;
	struct clk *clk_vout_src;

	struct reset_control *rst_disp_axi;
	struct reset_control *rst_vout_src;

	int		lcdc_irq;
	int		vpp0_irq;
	int		vpp1_irq;
	int		vpp2_irq;

	struct pp_mode	*pp;

	int		win_num;
	int		pp_conn_lcdc;
	unsigned int	ddr_format;
	bool		ddr_format_change;
	enum		COLOR_FORMAT vpp_format;
	int		lcdcfmt;

	/* one time only one process allowed to config the register */
	spinlock_t	reg_lock;

	struct drm_plane	*planes;

	u8		lut_r[256];
	u8		lut_g[256];
	u8		lut_b[256];

	bool		gamma_lut;
	dma_addr_t	dma_addr;
	bool		dma_addr_change;
	size_t		size;
};

#define to_starfive_crtc(x) container_of(x, struct starfive_crtc, crtc)

void starfive_crtc_hw_config_simple(struct starfive_crtc *starfive_crtc);

#endif /* _STARFIVE_DRM_CRTC_H */