162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2014 Traphandler 462306a36Sopenharmony_ci * Copyright (C) 2014 Free Electrons 562306a36Sopenharmony_ci * Copyright (C) 2014 Atmel 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Author: Jean-Jacques Hiblot <jjhiblot@traphandler.com> 862306a36Sopenharmony_ci * Author: Boris BREZILLON <boris.brezillon@free-electrons.com> 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#ifndef DRM_ATMEL_HLCDC_H 1262306a36Sopenharmony_ci#define DRM_ATMEL_HLCDC_H 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#include <linux/regmap.h> 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#include <drm/drm_plane.h> 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_CHER 0x0 1962306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_CHDR 0x4 2062306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_CHSR 0x8 2162306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_EN BIT(0) 2262306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_UPDATE BIT(1) 2362306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_A2Q BIT(2) 2462306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_RST BIT(8) 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_IER 0xc 2762306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_IDR 0x10 2862306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_IMR 0x14 2962306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_ISR 0x18 3062306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DFETCH BIT(0) 3162306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_LFETCH BIT(1) 3262306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_IRQ(p) BIT(2 + (8 * (p))) 3362306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DSCR_IRQ(p) BIT(3 + (8 * (p))) 3462306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_ADD_IRQ(p) BIT(4 + (8 * (p))) 3562306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DONE_IRQ(p) BIT(5 + (8 * (p))) 3662306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_OVR_IRQ(p) BIT(6 + (8 * (p))) 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_PLANE_HEAD(p) (((p) * 0x10) + 0x1c) 3962306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_PLANE_ADDR(p) (((p) * 0x10) + 0x20) 4062306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_PLANE_CTRL(p) (((p) * 0x10) + 0x24) 4162306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_PLANE_NEXT(p) (((p) * 0x10) + 0x28) 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_CFG 0 4462306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_SIF BIT(0) 4562306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_BLEN_MASK GENMASK(5, 4) 4662306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_BLEN_SINGLE (0 << 4) 4762306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_BLEN_INCR4 (1 << 4) 4862306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_BLEN_INCR8 (2 << 4) 4962306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_BLEN_INCR16 (3 << 4) 5062306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_DLBO BIT(8) 5162306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_ROTDIS BIT(12) 5262306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA_LOCKDIS BIT(13) 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_FORMAT_CFG 1 5562306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_RGB (0 << 0) 5662306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_CLUT (1 << 0) 5762306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_YUV (2 << 0) 5862306a36Sopenharmony_ci#define ATMEL_HLCDC_RGB_MODE(m) \ 5962306a36Sopenharmony_ci (ATMEL_HLCDC_LAYER_RGB | (((m) & 0xf) << 4)) 6062306a36Sopenharmony_ci#define ATMEL_HLCDC_CLUT_MODE(m) \ 6162306a36Sopenharmony_ci (ATMEL_HLCDC_LAYER_CLUT | (((m) & 0x3) << 8)) 6262306a36Sopenharmony_ci#define ATMEL_HLCDC_YUV_MODE(m) \ 6362306a36Sopenharmony_ci (ATMEL_HLCDC_LAYER_YUV | (((m) & 0xf) << 12)) 6462306a36Sopenharmony_ci#define ATMEL_HLCDC_YUV422ROT BIT(16) 6562306a36Sopenharmony_ci#define ATMEL_HLCDC_YUV422SWP BIT(17) 6662306a36Sopenharmony_ci#define ATMEL_HLCDC_DSCALEOPT BIT(20) 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define ATMEL_HLCDC_C1_MODE ATMEL_HLCDC_CLUT_MODE(0) 6962306a36Sopenharmony_ci#define ATMEL_HLCDC_C2_MODE ATMEL_HLCDC_CLUT_MODE(1) 7062306a36Sopenharmony_ci#define ATMEL_HLCDC_C4_MODE ATMEL_HLCDC_CLUT_MODE(2) 7162306a36Sopenharmony_ci#define ATMEL_HLCDC_C8_MODE ATMEL_HLCDC_CLUT_MODE(3) 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define ATMEL_HLCDC_XRGB4444_MODE ATMEL_HLCDC_RGB_MODE(0) 7462306a36Sopenharmony_ci#define ATMEL_HLCDC_ARGB4444_MODE ATMEL_HLCDC_RGB_MODE(1) 7562306a36Sopenharmony_ci#define ATMEL_HLCDC_RGBA4444_MODE ATMEL_HLCDC_RGB_MODE(2) 7662306a36Sopenharmony_ci#define ATMEL_HLCDC_RGB565_MODE ATMEL_HLCDC_RGB_MODE(3) 7762306a36Sopenharmony_ci#define ATMEL_HLCDC_ARGB1555_MODE ATMEL_HLCDC_RGB_MODE(4) 7862306a36Sopenharmony_ci#define ATMEL_HLCDC_XRGB8888_MODE ATMEL_HLCDC_RGB_MODE(9) 7962306a36Sopenharmony_ci#define ATMEL_HLCDC_RGB888_MODE ATMEL_HLCDC_RGB_MODE(10) 8062306a36Sopenharmony_ci#define ATMEL_HLCDC_ARGB8888_MODE ATMEL_HLCDC_RGB_MODE(12) 8162306a36Sopenharmony_ci#define ATMEL_HLCDC_RGBA8888_MODE ATMEL_HLCDC_RGB_MODE(13) 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#define ATMEL_HLCDC_AYUV_MODE ATMEL_HLCDC_YUV_MODE(0) 8462306a36Sopenharmony_ci#define ATMEL_HLCDC_YUYV_MODE ATMEL_HLCDC_YUV_MODE(1) 8562306a36Sopenharmony_ci#define ATMEL_HLCDC_UYVY_MODE ATMEL_HLCDC_YUV_MODE(2) 8662306a36Sopenharmony_ci#define ATMEL_HLCDC_YVYU_MODE ATMEL_HLCDC_YUV_MODE(3) 8762306a36Sopenharmony_ci#define ATMEL_HLCDC_VYUY_MODE ATMEL_HLCDC_YUV_MODE(4) 8862306a36Sopenharmony_ci#define ATMEL_HLCDC_NV61_MODE ATMEL_HLCDC_YUV_MODE(5) 8962306a36Sopenharmony_ci#define ATMEL_HLCDC_YUV422_MODE ATMEL_HLCDC_YUV_MODE(6) 9062306a36Sopenharmony_ci#define ATMEL_HLCDC_NV21_MODE ATMEL_HLCDC_YUV_MODE(7) 9162306a36Sopenharmony_ci#define ATMEL_HLCDC_YUV420_MODE ATMEL_HLCDC_YUV_MODE(8) 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_POS(x, y) ((x) | ((y) << 16)) 9462306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_SIZE(w, h) (((w) - 1) | (((h) - 1) << 16)) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_CRKEY BIT(0) 9762306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_INV BIT(1) 9862306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_ITER2BL BIT(2) 9962306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_ITER BIT(3) 10062306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_REVALPHA BIT(4) 10162306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_GAEN BIT(5) 10262306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_LAEN BIT(6) 10362306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_OVR BIT(7) 10462306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DMA BIT(8) 10562306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_REP BIT(9) 10662306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DSTKEY BIT(10) 10762306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DISCEN BIT(11) 10862306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_GA_SHIFT 16 10962306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_GA_MASK \ 11062306a36Sopenharmony_ci GENMASK(23, ATMEL_HLCDC_LAYER_GA_SHIFT) 11162306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_GA(x) \ 11262306a36Sopenharmony_ci ((x) << ATMEL_HLCDC_LAYER_GA_SHIFT) 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DISC_POS(x, y) ((x) | ((y) << 16)) 11562306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_DISC_SIZE(w, h) (((w) - 1) | (((h) - 1) << 16)) 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_SCALER_FACTORS(x, y) ((x) | ((y) << 16)) 11862306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_SCALER_ENABLE BIT(31) 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define ATMEL_HLCDC_LAYER_MAX_PLANES 3 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci#define ATMEL_HLCDC_DMA_CHANNEL_DSCR_RESERVED BIT(0) 12362306a36Sopenharmony_ci#define ATMEL_HLCDC_DMA_CHANNEL_DSCR_LOADED BIT(1) 12462306a36Sopenharmony_ci#define ATMEL_HLCDC_DMA_CHANNEL_DSCR_DONE BIT(2) 12562306a36Sopenharmony_ci#define ATMEL_HLCDC_DMA_CHANNEL_DSCR_OVERRUN BIT(3) 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci#define ATMEL_HLCDC_CLUT_SIZE 256 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci#define ATMEL_HLCDC_MAX_LAYERS 6 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci/** 13262306a36Sopenharmony_ci * Atmel HLCDC Layer registers layout structure 13362306a36Sopenharmony_ci * 13462306a36Sopenharmony_ci * Each HLCDC layer has its own register organization and a given register 13562306a36Sopenharmony_ci * can be placed differently on 2 different layers depending on its 13662306a36Sopenharmony_ci * capabilities. 13762306a36Sopenharmony_ci * This structure stores common registers layout for a given layer and is 13862306a36Sopenharmony_ci * used by HLCDC layer code to choose the appropriate register to write to 13962306a36Sopenharmony_ci * or to read from. 14062306a36Sopenharmony_ci * 14162306a36Sopenharmony_ci * For all fields, a value of zero means "unsupported". 14262306a36Sopenharmony_ci * 14362306a36Sopenharmony_ci * See Atmel's datasheet for a detailled description of these registers. 14462306a36Sopenharmony_ci * 14562306a36Sopenharmony_ci * @xstride: xstride registers 14662306a36Sopenharmony_ci * @pstride: pstride registers 14762306a36Sopenharmony_ci * @pos: position register 14862306a36Sopenharmony_ci * @size: displayed size register 14962306a36Sopenharmony_ci * @memsize: memory size register 15062306a36Sopenharmony_ci * @default_color: default color register 15162306a36Sopenharmony_ci * @chroma_key: chroma key register 15262306a36Sopenharmony_ci * @chroma_key_mask: chroma key mask register 15362306a36Sopenharmony_ci * @general_config: general layer config register 15462306a36Sopenharmony_ci * @sacler_config: scaler factors register 15562306a36Sopenharmony_ci * @phicoeffs: X/Y PHI coefficient registers 15662306a36Sopenharmony_ci * @disc_pos: discard area position register 15762306a36Sopenharmony_ci * @disc_size: discard area size register 15862306a36Sopenharmony_ci * @csc: color space conversion register 15962306a36Sopenharmony_ci */ 16062306a36Sopenharmony_cistruct atmel_hlcdc_layer_cfg_layout { 16162306a36Sopenharmony_ci int xstride[ATMEL_HLCDC_LAYER_MAX_PLANES]; 16262306a36Sopenharmony_ci int pstride[ATMEL_HLCDC_LAYER_MAX_PLANES]; 16362306a36Sopenharmony_ci int pos; 16462306a36Sopenharmony_ci int size; 16562306a36Sopenharmony_ci int memsize; 16662306a36Sopenharmony_ci int default_color; 16762306a36Sopenharmony_ci int chroma_key; 16862306a36Sopenharmony_ci int chroma_key_mask; 16962306a36Sopenharmony_ci int general_config; 17062306a36Sopenharmony_ci int scaler_config; 17162306a36Sopenharmony_ci struct { 17262306a36Sopenharmony_ci int x; 17362306a36Sopenharmony_ci int y; 17462306a36Sopenharmony_ci } phicoeffs; 17562306a36Sopenharmony_ci int disc_pos; 17662306a36Sopenharmony_ci int disc_size; 17762306a36Sopenharmony_ci int csc; 17862306a36Sopenharmony_ci}; 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci/** 18162306a36Sopenharmony_ci * Atmel HLCDC DMA descriptor structure 18262306a36Sopenharmony_ci * 18362306a36Sopenharmony_ci * This structure is used by the HLCDC DMA engine to schedule a DMA transfer. 18462306a36Sopenharmony_ci * 18562306a36Sopenharmony_ci * The structure fields must remain in this specific order, because they're 18662306a36Sopenharmony_ci * used by the HLCDC DMA engine, which expect them in this order. 18762306a36Sopenharmony_ci * HLCDC DMA descriptors must be aligned on 64 bits. 18862306a36Sopenharmony_ci * 18962306a36Sopenharmony_ci * @addr: buffer DMA address 19062306a36Sopenharmony_ci * @ctrl: DMA transfer options 19162306a36Sopenharmony_ci * @next: next DMA descriptor to fetch 19262306a36Sopenharmony_ci * @self: descriptor DMA address 19362306a36Sopenharmony_ci */ 19462306a36Sopenharmony_cistruct atmel_hlcdc_dma_channel_dscr { 19562306a36Sopenharmony_ci dma_addr_t addr; 19662306a36Sopenharmony_ci u32 ctrl; 19762306a36Sopenharmony_ci dma_addr_t next; 19862306a36Sopenharmony_ci dma_addr_t self; 19962306a36Sopenharmony_ci} __aligned(sizeof(u64)); 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ci/** 20262306a36Sopenharmony_ci * Atmel HLCDC layer types 20362306a36Sopenharmony_ci */ 20462306a36Sopenharmony_cienum atmel_hlcdc_layer_type { 20562306a36Sopenharmony_ci ATMEL_HLCDC_NO_LAYER, 20662306a36Sopenharmony_ci ATMEL_HLCDC_BASE_LAYER, 20762306a36Sopenharmony_ci ATMEL_HLCDC_OVERLAY_LAYER, 20862306a36Sopenharmony_ci ATMEL_HLCDC_CURSOR_LAYER, 20962306a36Sopenharmony_ci ATMEL_HLCDC_PP_LAYER, 21062306a36Sopenharmony_ci}; 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_ci/** 21362306a36Sopenharmony_ci * Atmel HLCDC Supported formats structure 21462306a36Sopenharmony_ci * 21562306a36Sopenharmony_ci * This structure list all the formats supported by a given layer. 21662306a36Sopenharmony_ci * 21762306a36Sopenharmony_ci * @nformats: number of supported formats 21862306a36Sopenharmony_ci * @formats: supported formats 21962306a36Sopenharmony_ci */ 22062306a36Sopenharmony_cistruct atmel_hlcdc_formats { 22162306a36Sopenharmony_ci int nformats; 22262306a36Sopenharmony_ci u32 *formats; 22362306a36Sopenharmony_ci}; 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci/** 22662306a36Sopenharmony_ci * Atmel HLCDC Layer description structure 22762306a36Sopenharmony_ci * 22862306a36Sopenharmony_ci * This structure describes the capabilities provided by a given layer. 22962306a36Sopenharmony_ci * 23062306a36Sopenharmony_ci * @name: layer name 23162306a36Sopenharmony_ci * @type: layer type 23262306a36Sopenharmony_ci * @id: layer id 23362306a36Sopenharmony_ci * @regs_offset: offset of the layer registers from the HLCDC registers base 23462306a36Sopenharmony_ci * @cfgs_offset: CFGX registers offset from the layer registers base 23562306a36Sopenharmony_ci * @formats: supported formats 23662306a36Sopenharmony_ci * @layout: config registers layout 23762306a36Sopenharmony_ci * @max_width: maximum width supported by this layer (0 means unlimited) 23862306a36Sopenharmony_ci * @max_height: maximum height supported by this layer (0 means unlimited) 23962306a36Sopenharmony_ci */ 24062306a36Sopenharmony_cistruct atmel_hlcdc_layer_desc { 24162306a36Sopenharmony_ci const char *name; 24262306a36Sopenharmony_ci enum atmel_hlcdc_layer_type type; 24362306a36Sopenharmony_ci int id; 24462306a36Sopenharmony_ci int regs_offset; 24562306a36Sopenharmony_ci int cfgs_offset; 24662306a36Sopenharmony_ci int clut_offset; 24762306a36Sopenharmony_ci struct atmel_hlcdc_formats *formats; 24862306a36Sopenharmony_ci struct atmel_hlcdc_layer_cfg_layout layout; 24962306a36Sopenharmony_ci int max_width; 25062306a36Sopenharmony_ci int max_height; 25162306a36Sopenharmony_ci}; 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci/** 25462306a36Sopenharmony_ci * Atmel HLCDC Layer. 25562306a36Sopenharmony_ci * 25662306a36Sopenharmony_ci * A layer can be a DRM plane of a post processing layer used to render 25762306a36Sopenharmony_ci * HLCDC composition into memory. 25862306a36Sopenharmony_ci * 25962306a36Sopenharmony_ci * @desc: layer description 26062306a36Sopenharmony_ci * @regmap: pointer to the HLCDC regmap 26162306a36Sopenharmony_ci */ 26262306a36Sopenharmony_cistruct atmel_hlcdc_layer { 26362306a36Sopenharmony_ci const struct atmel_hlcdc_layer_desc *desc; 26462306a36Sopenharmony_ci struct regmap *regmap; 26562306a36Sopenharmony_ci}; 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ci/** 26862306a36Sopenharmony_ci * Atmel HLCDC Plane. 26962306a36Sopenharmony_ci * 27062306a36Sopenharmony_ci * @base: base DRM plane structure 27162306a36Sopenharmony_ci * @layer: HLCDC layer structure 27262306a36Sopenharmony_ci * @properties: pointer to the property definitions structure 27362306a36Sopenharmony_ci */ 27462306a36Sopenharmony_cistruct atmel_hlcdc_plane { 27562306a36Sopenharmony_ci struct drm_plane base; 27662306a36Sopenharmony_ci struct atmel_hlcdc_layer layer; 27762306a36Sopenharmony_ci}; 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_cistatic inline struct atmel_hlcdc_plane * 28062306a36Sopenharmony_cidrm_plane_to_atmel_hlcdc_plane(struct drm_plane *p) 28162306a36Sopenharmony_ci{ 28262306a36Sopenharmony_ci return container_of(p, struct atmel_hlcdc_plane, base); 28362306a36Sopenharmony_ci} 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_cistatic inline struct atmel_hlcdc_plane * 28662306a36Sopenharmony_ciatmel_hlcdc_layer_to_plane(struct atmel_hlcdc_layer *layer) 28762306a36Sopenharmony_ci{ 28862306a36Sopenharmony_ci return container_of(layer, struct atmel_hlcdc_plane, layer); 28962306a36Sopenharmony_ci} 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci/** 29262306a36Sopenharmony_ci * Atmel HLCDC Display Controller description structure. 29362306a36Sopenharmony_ci * 29462306a36Sopenharmony_ci * This structure describes the HLCDC IP capabilities and depends on the 29562306a36Sopenharmony_ci * HLCDC IP version (or Atmel SoC family). 29662306a36Sopenharmony_ci * 29762306a36Sopenharmony_ci * @min_width: minimum width supported by the Display Controller 29862306a36Sopenharmony_ci * @min_height: minimum height supported by the Display Controller 29962306a36Sopenharmony_ci * @max_width: maximum width supported by the Display Controller 30062306a36Sopenharmony_ci * @max_height: maximum height supported by the Display Controller 30162306a36Sopenharmony_ci * @max_spw: maximum vertical/horizontal pulse width 30262306a36Sopenharmony_ci * @max_vpw: maximum vertical back/front porch width 30362306a36Sopenharmony_ci * @max_hpw: maximum horizontal back/front porch width 30462306a36Sopenharmony_ci * @conflicting_output_formats: true if RGBXXX output formats conflict with 30562306a36Sopenharmony_ci * each other. 30662306a36Sopenharmony_ci * @fixed_clksrc: true if clock source is fixed 30762306a36Sopenharmony_ci * @layers: a layer description table describing available layers 30862306a36Sopenharmony_ci * @nlayers: layer description table size 30962306a36Sopenharmony_ci */ 31062306a36Sopenharmony_cistruct atmel_hlcdc_dc_desc { 31162306a36Sopenharmony_ci int min_width; 31262306a36Sopenharmony_ci int min_height; 31362306a36Sopenharmony_ci int max_width; 31462306a36Sopenharmony_ci int max_height; 31562306a36Sopenharmony_ci int max_spw; 31662306a36Sopenharmony_ci int max_vpw; 31762306a36Sopenharmony_ci int max_hpw; 31862306a36Sopenharmony_ci bool conflicting_output_formats; 31962306a36Sopenharmony_ci bool fixed_clksrc; 32062306a36Sopenharmony_ci const struct atmel_hlcdc_layer_desc *layers; 32162306a36Sopenharmony_ci int nlayers; 32262306a36Sopenharmony_ci}; 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_ci/** 32562306a36Sopenharmony_ci * Atmel HLCDC Display Controller. 32662306a36Sopenharmony_ci * 32762306a36Sopenharmony_ci * @desc: HLCDC Display Controller description 32862306a36Sopenharmony_ci * @dscrpool: DMA coherent pool used to allocate DMA descriptors 32962306a36Sopenharmony_ci * @hlcdc: pointer to the atmel_hlcdc structure provided by the MFD device 33062306a36Sopenharmony_ci * @fbdev: framebuffer device attached to the Display Controller 33162306a36Sopenharmony_ci * @crtc: CRTC provided by the display controller 33262306a36Sopenharmony_ci * @planes: instantiated planes 33362306a36Sopenharmony_ci * @layers: active HLCDC layers 33462306a36Sopenharmony_ci * @suspend: used to store the HLCDC state when entering suspend 33562306a36Sopenharmony_ci */ 33662306a36Sopenharmony_cistruct atmel_hlcdc_dc { 33762306a36Sopenharmony_ci const struct atmel_hlcdc_dc_desc *desc; 33862306a36Sopenharmony_ci struct dma_pool *dscrpool; 33962306a36Sopenharmony_ci struct atmel_hlcdc *hlcdc; 34062306a36Sopenharmony_ci struct drm_crtc *crtc; 34162306a36Sopenharmony_ci struct atmel_hlcdc_layer *layers[ATMEL_HLCDC_MAX_LAYERS]; 34262306a36Sopenharmony_ci struct { 34362306a36Sopenharmony_ci u32 imr; 34462306a36Sopenharmony_ci struct drm_atomic_state *state; 34562306a36Sopenharmony_ci } suspend; 34662306a36Sopenharmony_ci}; 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_ciextern struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_formats; 34962306a36Sopenharmony_ciextern struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_and_yuv_formats; 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_cistatic inline void atmel_hlcdc_layer_write_reg(struct atmel_hlcdc_layer *layer, 35262306a36Sopenharmony_ci unsigned int reg, u32 val) 35362306a36Sopenharmony_ci{ 35462306a36Sopenharmony_ci regmap_write(layer->regmap, layer->desc->regs_offset + reg, val); 35562306a36Sopenharmony_ci} 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_cistatic inline u32 atmel_hlcdc_layer_read_reg(struct atmel_hlcdc_layer *layer, 35862306a36Sopenharmony_ci unsigned int reg) 35962306a36Sopenharmony_ci{ 36062306a36Sopenharmony_ci u32 val; 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci regmap_read(layer->regmap, layer->desc->regs_offset + reg, &val); 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci return val; 36562306a36Sopenharmony_ci} 36662306a36Sopenharmony_ci 36762306a36Sopenharmony_cistatic inline void atmel_hlcdc_layer_write_cfg(struct atmel_hlcdc_layer *layer, 36862306a36Sopenharmony_ci unsigned int cfgid, u32 val) 36962306a36Sopenharmony_ci{ 37062306a36Sopenharmony_ci atmel_hlcdc_layer_write_reg(layer, 37162306a36Sopenharmony_ci layer->desc->cfgs_offset + 37262306a36Sopenharmony_ci (cfgid * sizeof(u32)), val); 37362306a36Sopenharmony_ci} 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_cistatic inline u32 atmel_hlcdc_layer_read_cfg(struct atmel_hlcdc_layer *layer, 37662306a36Sopenharmony_ci unsigned int cfgid) 37762306a36Sopenharmony_ci{ 37862306a36Sopenharmony_ci return atmel_hlcdc_layer_read_reg(layer, 37962306a36Sopenharmony_ci layer->desc->cfgs_offset + 38062306a36Sopenharmony_ci (cfgid * sizeof(u32))); 38162306a36Sopenharmony_ci} 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_cistatic inline void atmel_hlcdc_layer_write_clut(struct atmel_hlcdc_layer *layer, 38462306a36Sopenharmony_ci unsigned int c, u32 val) 38562306a36Sopenharmony_ci{ 38662306a36Sopenharmony_ci regmap_write(layer->regmap, 38762306a36Sopenharmony_ci layer->desc->clut_offset + c * sizeof(u32), 38862306a36Sopenharmony_ci val); 38962306a36Sopenharmony_ci} 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_cistatic inline void atmel_hlcdc_layer_init(struct atmel_hlcdc_layer *layer, 39262306a36Sopenharmony_ci const struct atmel_hlcdc_layer_desc *desc, 39362306a36Sopenharmony_ci struct regmap *regmap) 39462306a36Sopenharmony_ci{ 39562306a36Sopenharmony_ci layer->desc = desc; 39662306a36Sopenharmony_ci layer->regmap = regmap; 39762306a36Sopenharmony_ci} 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_cienum drm_mode_status 40062306a36Sopenharmony_ciatmel_hlcdc_dc_mode_valid(struct atmel_hlcdc_dc *dc, 40162306a36Sopenharmony_ci const struct drm_display_mode *mode); 40262306a36Sopenharmony_ci 40362306a36Sopenharmony_ciint atmel_hlcdc_create_planes(struct drm_device *dev); 40462306a36Sopenharmony_civoid atmel_hlcdc_plane_irq(struct atmel_hlcdc_plane *plane); 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ciint atmel_hlcdc_plane_prepare_disc_area(struct drm_crtc_state *c_state); 40762306a36Sopenharmony_ciint atmel_hlcdc_plane_prepare_ahb_routing(struct drm_crtc_state *c_state); 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_civoid atmel_hlcdc_crtc_irq(struct drm_crtc *c); 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ciint atmel_hlcdc_crtc_create(struct drm_device *dev); 41262306a36Sopenharmony_ci 41362306a36Sopenharmony_ciint atmel_hlcdc_create_outputs(struct drm_device *dev); 41462306a36Sopenharmony_ciint atmel_hlcdc_encoder_get_bus_fmt(struct drm_encoder *encoder); 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ci#endif /* DRM_ATMEL_HLCDC_H */ 417