18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) Jernej Skrabec <jernej.skrabec@siol.net> 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef _SUN8I_VI_LAYER_H_ 78c2ecf20Sopenharmony_ci#define _SUN8I_VI_LAYER_H_ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <drm/drm_plane.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_LAYER_ATTR(base, layer) \ 128c2ecf20Sopenharmony_ci ((base) + 0x30 * (layer) + 0x0) 138c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_LAYER_SIZE(base, layer) \ 148c2ecf20Sopenharmony_ci ((base) + 0x30 * (layer) + 0x4) 158c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_LAYER_COORD(base, layer) \ 168c2ecf20Sopenharmony_ci ((base) + 0x30 * (layer) + 0x8) 178c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_LAYER_PITCH(base, layer, plane) \ 188c2ecf20Sopenharmony_ci ((base) + 0x30 * (layer) + 0xc + 4 * (plane)) 198c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_LAYER_TOP_LADDR(base, layer, plane) \ 208c2ecf20Sopenharmony_ci ((base) + 0x30 * (layer) + 0x18 + 4 * (plane)) 218c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_OVL_SIZE(base) \ 228c2ecf20Sopenharmony_ci ((base) + 0xe8) 238c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_HDS_Y(base) \ 248c2ecf20Sopenharmony_ci ((base) + 0xf0) 258c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_HDS_UV(base) \ 268c2ecf20Sopenharmony_ci ((base) + 0xf4) 278c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_VDS_Y(base) \ 288c2ecf20Sopenharmony_ci ((base) + 0xf8) 298c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_VDS_UV(base) \ 308c2ecf20Sopenharmony_ci ((base) + 0xfc) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN BIT(0) 338c2ecf20Sopenharmony_ci/* RGB mode should be set for RGB formats and cleared for YCbCr */ 348c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_LAYER_ATTR_RGB_MODE BIT(15) 358c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_LAYER_ATTR_FBFMT_OFFSET 8 368c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_LAYER_ATTR_FBFMT_MASK GENMASK(12, 8) 378c2ecf20Sopenharmony_ci#define SUN50I_MIXER_CHAN_VI_LAYER_ATTR_ALPHA_MASK GENMASK(31, 24) 388c2ecf20Sopenharmony_ci#define SUN50I_MIXER_CHAN_VI_LAYER_ATTR_ALPHA(x) ((x) << 24) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_DS_N(x) ((x) << 16) 418c2ecf20Sopenharmony_ci#define SUN8I_MIXER_CHAN_VI_DS_M(x) ((x) << 0) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistruct sun8i_mixer; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct sun8i_vi_layer { 468c2ecf20Sopenharmony_ci struct drm_plane plane; 478c2ecf20Sopenharmony_ci struct sun8i_mixer *mixer; 488c2ecf20Sopenharmony_ci int channel; 498c2ecf20Sopenharmony_ci int overlay; 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic inline struct sun8i_vi_layer * 538c2ecf20Sopenharmony_ciplane_to_sun8i_vi_layer(struct drm_plane *plane) 548c2ecf20Sopenharmony_ci{ 558c2ecf20Sopenharmony_ci return container_of(plane, struct sun8i_vi_layer, plane); 568c2ecf20Sopenharmony_ci} 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct sun8i_vi_layer *sun8i_vi_layer_init_one(struct drm_device *drm, 598c2ecf20Sopenharmony_ci struct sun8i_mixer *mixer, 608c2ecf20Sopenharmony_ci int index); 618c2ecf20Sopenharmony_ci#endif /* _SUN8I_VI_LAYER_H_ */ 62